From patchwork Mon Jun 20 17:52:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 583189 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp930581mab; Mon, 20 Jun 2022 11:15:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v6QxUdztl4jpJBQZpofclOwSSiB0mi1R7TJZM0xhvxt/q7qYDBEFoxYPldImsTBhKbU16e X-Received: by 2002:a05:622a:24a:b0:305:25c2:323e with SMTP id c10-20020a05622a024a00b0030525c2323emr20953302qtx.167.1655748938359; Mon, 20 Jun 2022 11:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655748938; cv=none; d=google.com; s=arc-20160816; b=xjJ1j+5sOmsc4IIQKbXqXkjMpo1v2OQH68hRFkinz01nQe+9K7skObrSquhbygNhpL rZ1f2xL9dYSxSv/iyxsweSi2vRc79CAIq8nD6VgbdLoZOeEgfHCuT/8MHcukczcHX72q Pq8pR5yWDbPCoYbwx9UNtMyDMcVMxSK4k3fbcZAjIhpbf9ifGlgWuX6sLYK5IoIc8O0Y GamMmEsjUeRl2idXdRRgwBdptaVY0RPRSX3YCd7xYU4WEaaOKWynNHZNRkwMx8VExV3X 3PkZEYsJydwIzoHjqB9VeWPwcNkGXGlJ9PQdWHgiUL4qIMKarFz6NPqixH0UyRLRmUW9 bgcg== 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=E4K6DCOe/i36LDuzHkwFG31IRZwDb3VpHryjLqKCC5U=; b=sRwMIkEadPPXJ2ze9/99lFI1gUg6/nTl/VFb1hXcHj3VdrbFrdp1TmT1bWEpO+Xnj0 yiMa5rUCblNDH2RsDY3ucuvVL+B0WomYFBSKyaEJetyfmE5vjLLUG6H3MsHbEiQuaCwk 7F21d/tnpl7QjnjUvFlQofO2iR4fCIN1CTydJASDTdkYLxNIvzus9i2hyJc4doBrcjDo d3hgwhIMMVAgdEafmhoPvVrE4oe1oHC8s+loxXAz2XXNhoKr0JlA9LwA1L7zSC4CyXAC Y+bm1LsEcdB5m1NVam0m4sjZL8Acfd1tLLrGVl05JNeknh3xG56vKTKBSs/vLw6CA/6u qQrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zgp6BLTP; 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 q3-20020a0c9a43000000b0047046ce1856si1292313qvd.58.2022.06.20.11.15.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jun 2022 11:15:38 -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=Zgp6BLTP; 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]:45232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3Lw1-00046K-Qi for patch@linaro.org; Mon, 20 Jun 2022 14:15:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3LaH-0006NM-BQ for qemu-devel@nongnu.org; Mon, 20 Jun 2022 13:53:11 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:45972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3LaB-0001QA-26 for qemu-devel@nongnu.org; Mon, 20 Jun 2022 13:53:07 -0400 Received: by mail-pg1-x536.google.com with SMTP id 184so10881344pga.12 for ; Mon, 20 Jun 2022 10:53:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E4K6DCOe/i36LDuzHkwFG31IRZwDb3VpHryjLqKCC5U=; b=Zgp6BLTP0NJtrGt4w5PrwcAiNOYUjxhfO3KjKqtISNQ+os/+EWOXeVUwd2c6VsjG2N K84N9mzYJbkC8XDtmUgtgPJgT5LVLoTEJ543YM6D/GhsTIPHqXTIhucAhhU0vs7Whxks mdgTfkeX460fXkcEUOhc2UM9Q54UpGVE+1FvER14EvLk/VBPmT2k6gSeNUSKu1Um+pe5 kQ1gygfvGoWuAUMw7/TM1ePFu+DOt8fg8WaFSxBzthkCVyCEB88865DkrZZVNPN0+0Ab Hq9nR7SToqmkt1UypsbPNwWS+ty+ix9Zz1LtMynpxPJRzmm9G1/cMdItlCgdAdYIsMRM rttg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E4K6DCOe/i36LDuzHkwFG31IRZwDb3VpHryjLqKCC5U=; b=gRTg3AoAZWkL3BQuqKNQavIU9Tc0ERXkR+5sOcCt0YwCExz8yfZn32+7Yh54nZQmf/ PSEY2qCT38Gkql909v4hlrnz6nQ+nAjKH/dSyKyoGL1HzsZ3YTKlMnxmXOgnEcTCSVdJ V8gcoH0EwRKd4S2fYEuZI3kDi+1NFQ6BlgRjVBa7sxn5AE3exXvHmZ0UMK7KS61VyG2P Qnhu2el5rzNcriCvhicNjglk43MRcvh52NGUImCRoU3SqDQnw9WIUsxOGba//y57SMuB 2DkLrD1oYV82OmdAaaEc2q2sQWETFhzW8yTLytZCDmgEZ4bNZi3+28Iuwrt3wY1SzfC7 D0sw== X-Gm-Message-State: AJIora9X8J8hikvVPh2hsYPKN9bpcfiy/HdjATMtO0Ke51ElLPodllP6 SNqTVUdb09zV67+qBQr/AV66v5n0IvfmDQ== X-Received: by 2002:a62:e919:0:b0:51e:7b6e:5a3b with SMTP id j25-20020a62e919000000b0051e7b6e5a3bmr26159669pfh.78.1655747581735; Mon, 20 Jun 2022 10:53:01 -0700 (PDT) Received: from stoup.. ([2602:47:d49e:3c01:a3e0:8a80:7b85:aea6]) by smtp.gmail.com with ESMTPSA id j14-20020aa7928e000000b00525133f98adsm5138138pfa.146.2022.06.20.10.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 10:53:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v3 29/51] target/arm: Implement SME ADDHA, ADDVA Date: Mon, 20 Jun 2022 10:52:13 -0700 Message-Id: <20220620175235.60881-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220620175235.60881-1-richard.henderson@linaro.org> References: <20220620175235.60881-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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" Signed-off-by: Richard Henderson --- target/arm/helper-sme.h | 5 +++ target/arm/sme.decode | 11 +++++ target/arm/sme_helper.c | 90 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-sme.c | 30 +++++++++++++ 4 files changed, 136 insertions(+) diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h index 5cca01f372..6f0fce7e2c 100644 --- a/target/arm/helper-sme.h +++ b/target/arm/helper-sme.h @@ -114,3 +114,8 @@ DEF_HELPER_FLAGS_5(sme_st1q_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i DEF_HELPER_FLAGS_5(sme_st1q_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) DEF_HELPER_FLAGS_5(sme_st1q_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) DEF_HELPER_FLAGS_5(sme_st1q_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_5(sme_addha_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sme_addva_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) diff --git a/target/arm/sme.decode b/target/arm/sme.decode index f1ebd857a5..8cb6c4053c 100644 --- a/target/arm/sme.decode +++ b/target/arm/sme.decode @@ -53,3 +53,14 @@ LDST1 1110000 111 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \ LDR 1110000 100 0 000000 .. 000 ..... 0 .... @ldstr STR 1110000 100 1 000000 .. 000 ..... 0 .... @ldstr + +### SME Add Vector to Array + +&adda zad zn pm pn +@adda_32 ........ .. ..... . pm:3 pn:3 zn:5 ... zad:2 &adda +@adda_64 ........ .. ..... . pm:3 pn:3 zn:5 .. zad:3 &adda + +ADDHA_s 11000000 10 01000 0 ... ... ..... 000 .. @adda_32 +ADDVA_s 11000000 10 01000 1 ... ... ..... 000 .. @adda_32 +ADDHA_d 11000000 11 01000 0 ... ... ..... 00 ... @adda_64 +ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64 diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index 0c51fbbd49..799e44c047 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -807,3 +807,93 @@ DO_ST(q, _be, MO_128) DO_ST(q, _le, MO_128) #undef DO_ST + +void HELPER(sme_addha_s)(void *vzda, void *vzn, void *vpn, + void *vpm, uint32_t desc) +{ + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; + uint64_t *pn = vpn, *pm = vpm; + uint32_t * restrict zda = vzda, * restrict zn = vzn; + + for (row = 0; row < oprsz; ) { + uint64_t pa = pn[row >> 4]; + do { + if (pa & 1) { + for (col = 0; col < oprsz; ) { + uint64_t pb = pm[col >> 4]; + do { + if (pb & 1) { + zda[row * sizeof(ARMVectorReg) + col] += zn[col]; + } + pb >>= 4; + } while (++col & 15); + } + } + pa >>= 4; + } while (++row & 15); + } +} + +void HELPER(sme_addha_d)(void *vzda, void *vzn, void *vpn, + void *vpm, uint32_t desc) +{ + intptr_t row, col, oprsz = simd_oprsz(desc) / 8; + uint8_t *pn = vpn, *pm = vpm; + uint64_t * restrict zda = vzda, * restrict zn = vzn; + + for (row = 0; row < oprsz; ++row) { + if (pn[H1(row)] & 1) { + for (col = 0; col < oprsz; ++col) { + if (pm[H1(col)] & 1) { + zda[row * sizeof(ARMVectorReg) + col] += zn[col]; + } + } + } + } +} + +void HELPER(sme_addva_s)(void *vzda, void *vzn, void *vpn, + void *vpm, uint32_t desc) +{ + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; + uint64_t *pn = vpn, *pm = vpm; + uint32_t * restrict zda = vzda, * restrict zn = vzn; + + for (row = 0; row < oprsz; ) { + uint64_t pa = pn[row >> 4]; + do { + if (pa & 1) { + uint32_t zn_row = zn[row]; + for (col = 0; col < oprsz; ) { + uint64_t pb = pm[col >> 4]; + do { + if (pb & 1) { + zda[row * sizeof(ARMVectorReg) + col] += zn_row; + } + pb >>= 4; + } while (++col & 15); + } + } + pa >>= 4; + } while (++row & 15); + } +} + +void HELPER(sme_addva_d)(void *vzda, void *vzn, void *vpn, + void *vpm, uint32_t desc) +{ + intptr_t row, col, oprsz = simd_oprsz(desc) / 8; + uint8_t *pn = vpn, *pm = vpm; + uint64_t * restrict zda = vzda, * restrict zn = vzn; + + for (row = 0; row < oprsz; ++row) { + if (pn[H1(row)] & 1) { + uint64_t zn_row = zn[row]; + for (col = 0; col < oprsz; ++col) { + if (pm[H1(col)] & 1) { + zda[row * sizeof(ARMVectorReg) + col] += zn_row; + } + } + } + } +} diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c index c3e544d69c..e9676b2415 100644 --- a/target/arm/translate-sme.c +++ b/target/arm/translate-sme.c @@ -243,3 +243,33 @@ static bool do_ldst_r(DisasContext *s, arg_ldstr *a, GenLdStR *fn) TRANS_FEAT(LDR, aa64_sme, do_ldst_r, a, gen_sve_ldr) TRANS_FEAT(STR, aa64_sme, do_ldst_r, a, gen_sve_str) + +static bool do_adda(DisasContext *s, arg_adda *a, MemOp esz, + gen_helper_gvec_4 *fn) +{ + uint32_t desc = simd_desc(s->svl, s->svl, 0); + TCGv_ptr za, zn, pn, pm; + + if (!sme_smza_enabled_check(s)) { + return true; + } + + /* Sum XZR+zad to find ZAd. */ + za = get_tile_rowcol(s, esz, 31, a->zad, false); + zn = vec_full_reg_ptr(s, a->zn); + pn = pred_full_reg_ptr(s, a->pn); + pm = pred_full_reg_ptr(s, a->pm); + + fn(za, zn, pn, pm, tcg_constant_i32(desc)); + + tcg_temp_free_ptr(za); + tcg_temp_free_ptr(zn); + tcg_temp_free_ptr(pn); + tcg_temp_free_ptr(pm); + return true; +} + +TRANS_FEAT(ADDHA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addha_s) +TRANS_FEAT(ADDVA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addva_s) +TRANS_FEAT(ADDHA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addha_d) +TRANS_FEAT(ADDVA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addva_d)