From patchwork Tue Jun 7 20:32:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579370 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5531975max; Tue, 7 Jun 2022 14:36:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyKhP1s6/sJJKlGUEiHJAz9DWvuS3Mlti3/29zCq2PZe1f1cH1KHsVps5J1t2yRzRsx1uF X-Received: by 2002:a05:622a:34a:b0:304:f25a:ecf0 with SMTP id r10-20020a05622a034a00b00304f25aecf0mr7630460qtw.62.1654637812042; Tue, 07 Jun 2022 14:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654637812; cv=none; d=google.com; s=arc-20160816; b=fCLFlTSe7IcQoiGNlThmAP0dguKlN1JlLVYmSHqmC9Ao4fm1f9EHBM1MbibiE6NrH7 zrjWjxf/EEnJmDGVoj7ZP33qBGYkz9zIw1ICaL1XXi4xZaj3ozv7y4QiecGQkfhBSrn9 wJOysZPlGYp1oEtS+tBcCw6JA17UzKGemgudBss2DRPoCptnqYjgwjZxAwYqe8snBzCk aDSaYcUizI1XvlCcec0bMpEj3jTm6Ww3XBFkkLRuPDhzF/fS0TE0broTveuuXptPLyeK 40iQh0CidN0P8s3C5mX8BIum31h9A7zm/KBvTao6lVEVrpcVFq/yPyPm5qY36vyqNCKl d02g== 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=DNBS91YwaJoAlRAqtjXfPNlaKmUk7UCXcyJzeo6grF4=; b=Zj9I6S22QZSuolWAASgQpSnt/neTMWwDNqi/uQpKO270N/t+cpzpyi90QIW8F21dSj Huvdjq4JbS4VlX7G8oyQC99OxJpbcO2hr7TMULKIkeAx3YtqcbtvkvggP5sN3sUq6ToT 0eJPU4qT7R4zkIH2g2rD38i5jgcXofthGavP2N5LLE8V6EjERT6cpxxQSryvTlR2IWBV E0vf0hUqrkz39e7euAqwDId/rX3/SJsuXoMBOIvrlwQd4WbA6PYgj9xCay+7cWHWOzzc IXRHF52B0balBe6WhmU/HwmicwK/9l1DR/wCzy6oAglQZyKDOqErt7mCRekSqzcHYbnj AJ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aqprBCe4; 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 m6-20020ad45dc6000000b0046b99105c1bsi3623282qvh.525.2022.06.07.14.36.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 14:36:52 -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=aqprBCe4; 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]:56136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nygsd-0005jy-Hd for patch@linaro.org; Tue, 07 Jun 2022 17:36:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyfwl-0006if-86 for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:37:03 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:40851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyfwe-0008Hc-Ji for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:37:02 -0400 Received: by mail-pg1-x536.google.com with SMTP id f65so6759585pgc.7 for ; Tue, 07 Jun 2022 13:36:56 -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=DNBS91YwaJoAlRAqtjXfPNlaKmUk7UCXcyJzeo6grF4=; b=aqprBCe4ntY4enFLuGnDhQ3tpPd5Av44LCdqRRy8mTjoNGT/rdbTI+19f3Ox4ZtILy 0RFBkD1zjdrbDO17QJ20AqZqS3Z9eCkQds98M0B0p+uk7HYvbLgaWbyuVJ+MXm1hzoie X0xTWY5QgtSUrws+6UUSIfUvGJ7epHOfrJh56e7+TRoq9xthgQdM2BoQ+GyJIRslMA9R f/ydM7mHZF0Xh6817ByLM9bIBYarY8XukJmCZIoJvYcE6hTqYA9I408oJwbBoxm8yqCi SYiJhUKVdA3UHO+aUGXtCalwYreBc8FTcqtaiqQhPEXRRjreT1rGiDcBEiRyK6GKu8f3 pC8Q== 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=DNBS91YwaJoAlRAqtjXfPNlaKmUk7UCXcyJzeo6grF4=; b=5tXsJPfnt/9Mr93AGURWk/xA72AGhjplcTPF2xJ7zw9e7ZcaGNUPdtBz/c7lnVATr0 v89MY3jL/MVJCTqkk+gUPEymSE6dBurHFsyXkn07mVUHh9HqxA21DsVQMhswVwA+Zuyx v9v8o+f7AasgUrjFNi7FBH29wPtwybsaqCJj4e66omrdar7U7Norh4etMMRBZ3oFVCy/ g9rMfLBPpzrROZR32LwKrv6EBgy4XxgGuXDtOCPmvFeSahXX7rKem4ihKXaBZwOYI9ja q1mTpBRJxI+7lmZghVZLr+pWH2npjgad762AUCDZpQsKZ7hxfyUT46tO1XG1XG+ejBJj Hgbw== X-Gm-Message-State: AOAM532N0yWtLX1miTWmiGaV9wApPImi9Ps1G2wgDpvlqkfLpw69jDVv IfOfO77/E1PC8KswYYYxryk7gMOtQVweSw== X-Received: by 2002:a05:6a00:22cf:b0:51c:11c2:4bb with SMTP id f15-20020a056a0022cf00b0051c11c204bbmr13842715pfj.54.1654634215295; Tue, 07 Jun 2022 13:36:55 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3cf2:c634:5b19:25f6]) by smtp.gmail.com with ESMTPSA id s18-20020aa78d52000000b0050dc76281fdsm13235645pfe.215.2022.06.07.13.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:36:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Subject: [PATCH v2 51/71] target/arm: Implement BFMOPA, BFMOPS Date: Tue, 7 Jun 2022 13:32:46 -0700 Message-Id: <20220607203306.657998-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220607203306.657998-1-richard.henderson@linaro.org> References: <20220607203306.657998-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 | 2 ++ target/arm/sme_helper.c | 52 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-sme.c | 29 +++++++++++++++++++++ target/arm/sme.decode | 2 ++ 4 files changed, 85 insertions(+) diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h index 727095a3eb..6b36542133 100644 --- a/target/arm/helper-sme.h +++ b/target/arm/helper-sme.h @@ -124,3 +124,5 @@ DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_6(sme_bfmopa, TCG_CALL_NO_RWG, + void, ptr, ptr, ptr, ptr, ptr, i32) diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index 62d9690cae..61bab73cb7 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -964,3 +964,55 @@ void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn, set_default_nan_mode(save_dn, vst); } + +/* + * Alter PAIR as needed for controlling predicates being false, + * and for NEG on an enabled row element. + */ +static inline uint32_t f16mop_adj_pair(uint32_t pair, uint32_t pg, uint32_t neg) +{ + pair ^= neg; + if (!(pg & 1)) { + pair &= 0xffff0000u; + } + if (!(pg & 4)) { + pair &= 0x0000ffffu; + } + return pair; +} + +void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, + void *vpm, uint32_t desc) +{ + intptr_t row, col, oprsz = simd_maxsz(desc); + uint32_t neg = simd_data(desc) << 15; + uint16_t *pn = vpn, *pm = vpm; + + for (row = 0; row < oprsz; ) { + uint16_t pa = pn[H2(row >> 4)]; + do { + void *vza_row = vza + row * sizeof(ARMVectorReg); + uint32_t n = *(uint32_t *)(vzn + row); + + n = f16mop_adj_pair(n, pa, neg); + + for (col = 0; col < oprsz; ) { + uint16_t pb = pm[H2(col >> 4)]; + do { + if ((pa & 0b0101) == 0b0101 || (pb & 0b0101) == 0b0101) { + uint32_t *a = vza_row + col; + uint32_t m = *(uint32_t *)(vzm + col); + + m = f16mop_adj_pair(m, pb, neg); + *a = bfdotadd(*a, n, m); + + col += 4; + pb >>= 4; + } + } while (col & 15); + } + row += 4; + pa >>= 4; + } while (row & 15); + } +} diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c index e6e4541e76..581bf9174f 100644 --- a/target/arm/translate-sme.c +++ b/target/arm/translate-sme.c @@ -274,6 +274,32 @@ 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) +static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz, + gen_helper_gvec_5 *fn) +{ + uint32_t desc = simd_desc(s->svl, s->svl, a->sub); + TCGv_ptr za, zn, zm, 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); + zm = vec_full_reg_ptr(s, a->zm); + pn = pred_full_reg_ptr(s, a->pn); + pm = pred_full_reg_ptr(s, a->pm); + + fn(za, zn, zm, 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; +} + static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, gen_helper_gvec_5_ptr *fn) { @@ -306,3 +332,6 @@ TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s) TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d) + +/* TODO: FEAT_EBF16 */ +TRANS_FEAT(BFMOPA, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_bfmopa) diff --git a/target/arm/sme.decode b/target/arm/sme.decode index ba4774d174..afd9c0dffd 100644 --- a/target/arm/sme.decode +++ b/target/arm/sme.decode @@ -73,3 +73,5 @@ ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64 FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32 FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64 + +BFMOPA 10000001 100 ..... ... ... ..... . 00 .. @op_32