From patchwork Mon Jul 11 13:57:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 589372 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp3298901mab; Mon, 11 Jul 2022 07:29:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1a7Nw2fsYkwReoQkcbYVvWmD+Sl1QQB+Dq5D/6H2dyc6q8wSqxx+ejsjBg5D7RrK2hny8 X-Received: by 2002:a05:620a:214b:b0:6b5:8292:d8a8 with SMTP id m11-20020a05620a214b00b006b58292d8a8mr4086952qkm.776.1657549750260; Mon, 11 Jul 2022 07:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657549750; cv=none; d=google.com; s=arc-20160816; b=s4vioRp/HdZT3pbLqJz24Ff3yt/gpyDX/HrppbrybLO6AnPJ+GPJCVV4Zk+cyb3ets 6SdK1Vesg4oHs+QDAFuph8LWk7boVFX92eVph3AFAfaj90FsKTVPonDBebAQ0e/X8syZ oNlQ9KjbqvyFIQwssXdOHl9FR6/+vJHgyRCxj4Y1hcWwbh0RPL2vCkqaFw1v/mDwa4nt 4CMBEZV3CNpIrp5vhvQMEDyyVb6K++LFi9rMzLGkksCpMncPVSVKYy6nnhWB/oHGE/Bw i0erl3n2Z4XgykCeVilbOt64dMBudptmBgHAwR9jHsuQSiLFslL1dqNhVQDo8Kmd6C2O uxWQ== 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:to:from :dkim-signature; bh=Jrs2Elt6zkurq1tlTCd5KnpdSWVFVT+ucLNxgSmBuew=; b=wxO+dTb6QGAMlL5FKZIymqBMxiik4LcJOJieKWKv6Yo23xy8Jjf3toxb6qtdNY7R7a hCvDBC4xwd2qYqyxVVLQSJEDeW52/g0BbRFhIGo6pfwdv7byea3QIxDlP8z5SDpHPSfI W/HnP4/iKSNJpjxXxlPk1xllVYrYCnxUT35BARdAK4O9K1fJ3XCcQE3R4IBhJbzhE9nn m5EjnI+vQeQOTC/2HCRGYn7r2FisvUW2xB7O9iTYMMCxumuMlTvl8ZG7fbUynmENpeNK gqg1iWj3G5kJ19rCumrv4JsutkkWF9uCcLoNkJNe4dQst66ybcB/LtNTqk7Kbe1T56G3 Mr8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GT8KSd6f; 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 bs7-20020ac86f07000000b00315fc7161desi4114805qtb.98.2022.07.11.07.29.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jul 2022 07:29:10 -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=GT8KSd6f; 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]:37914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oAuPN-0003VD-Om for patch@linaro.org; Mon, 11 Jul 2022 10:29:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAtvV-0006Z1-PA for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:18 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:37550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oAtvS-0002qz-CY for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:17 -0400 Received: by mail-wr1-x432.google.com with SMTP id r10so971997wrv.4 for ; Mon, 11 Jul 2022 06:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Jrs2Elt6zkurq1tlTCd5KnpdSWVFVT+ucLNxgSmBuew=; b=GT8KSd6fxDz6IApczFfCTGtQBw2Q7iijiLM2gM6E+KAiHsOH9986wGqM8SF816/rDA XgNwqpblKttN+tW6TjyaTRpuMy40MsHSeo1+NTpZxSB7qR9Xgxh0hrtWUl8rfqZAI3ZU ZMd72BVY/3Ig3fZCZaPxdKvz/y1Am2Dn7IEvbGr4rxYkjC3k1ItH8/npd6DzjxBBea68 M2k+cEo+/lsuQkMghiMrdVVtccO6tGxstvO8+gEqWVZqkgCkrABZctcozwndvl11S9yC xA8GeaTvbApvWXA/iJqv6miJX1vwhiOcxU/mQxlUcnHkGWwuguhpWjvWLQlK2ojV62Nb /Grw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jrs2Elt6zkurq1tlTCd5KnpdSWVFVT+ucLNxgSmBuew=; b=e0/mNvSRAu0uaPr1JloSQyF+ArM1a4wsYze5bmKPaz20RP2jZtR2brmLhXu5W68Jb5 ewFOXRMHy5Dl+WGCNjwyKEqBPrqLI+PyZzMEJgTBJx0MUTYWFBD3E4qX6cLB0a/CjhlK vtrtnnyGTkbnZcFZizn6R4TMi9tTyNUOWv0zt3CO9oOvkjB0YOHs8oJdpiXlTH0X11Am 8dufvjsQkcqjZ3f265i5Y//AZKChW8/drLpQiNgKGPLnvx1bk1ugQUs8+awOnjNYyGPP yghhsVwwS+Fhc8ePHjIIq38TNRYjuf9RLmvaYZBNlyPrzjAQLzukYTj0tFFeIH22DZC5 sPJg== X-Gm-Message-State: AJIora/uxapHApd8LeeBTNIUk/HmbeSi1vCrIu+WRTbxNubCy0NJa0A5 uGL0zDvlSxigtEjLo42pURbcV8b8z1AmZA== X-Received: by 2002:a05:6000:81e:b0:21d:8811:777b with SMTP id bt30-20020a056000081e00b0021d8811777bmr17166950wrb.647.1657547891731; Mon, 11 Jul 2022 06:58:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id q123-20020a1c4381000000b00397402ae674sm7595596wma.11.2022.07.11.06.58.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 06:58:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/45] target/arm: Implement SME ADDHA, ADDVA Date: Mon, 11 Jul 2022 14:57:28 +0100 Message-Id: <20220711135750.765803-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711135750.765803-1-peter.maydell@linaro.org> References: <20220711135750.765803-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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" From: Richard Henderson Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220708151540.18136-24-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper-sme.h | 5 +++ target/arm/sme.decode | 11 +++++ target/arm/sme_helper.c | 90 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-sme.c | 31 +++++++++++++ 4 files changed, 137 insertions(+) diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h index 95f6e88bdd4..753e9e624cc 100644 --- a/target/arm/helper-sme.h +++ b/target/arm/helper-sme.h @@ -115,3 +115,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 f1ebd857a57..8cb6c4053c3 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 10fd1ed910d..f1e924db748 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -828,3 +828,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 *zda = vzda, *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[tile_vslice_index(row) + H4(col)] += zn[H4(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 *zda = vzda, *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[tile_vslice_index(row) + 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 *zda = vzda, *zn = vzn; + + for (row = 0; row < oprsz; ) { + uint64_t pa = pn[row >> 4]; + do { + if (pa & 1) { + uint32_t zn_row = zn[H4(row)]; + for (col = 0; col < oprsz; ) { + uint64_t pb = pm[col >> 4]; + do { + if (pb & 1) { + zda[tile_vslice_index(row) + H4(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 *zda = vzda, *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[tile_vslice_index(row) + col] += zn_row; + } + } + } + } +} diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c index 35c26448125..d3b9cdd5c4b 100644 --- a/target/arm/translate-sme.c +++ b/target/arm/translate-sme.c @@ -267,3 +267,34 @@ 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) +{ + int svl = streaming_vec_reg_size(s); + uint32_t desc = simd_desc(svl, 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)