From patchwork Mon Jul 11 13:57:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 589359 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp3283908mab; Mon, 11 Jul 2022 07:12:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vb2x6j03mEP6Gs0Q5lxQgKywxdVIAXxHnN7I1Bs4HJPJnrmKcwudlglRrOiq5sb8cpstUR X-Received: by 2002:a05:620a:2491:b0:6b5:9537:2cdc with SMTP id i17-20020a05620a249100b006b595372cdcmr1187079qkn.205.1657548757898; Mon, 11 Jul 2022 07:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657548757; cv=none; d=google.com; s=arc-20160816; b=jTFqDEbMmrD5gk2OXx7MnNoFOxtn6ae4bwXDOvi8scJEw8ioATHXWTOfzQPdJMBGlp 09dTRAgvgnRo3ZCAP6yqqawDnrebpsg4bvZHMrYABqAK4eGKYWncD0S0mGoZk8nbEwFt OLz3+IRY3a1uOFFCTdzInzpMG7F0i4Va8xaquGqWNrIr8fpBQd+Q2Boe1KsELsmAwfcu enb5O2thf45pU0+01cDu7AHFUr7MqrmshPILRZsA1qc08wbvY/DWXQC0+oC36QywaebH 5Yvc1zFeTq84jrxBorxwVdEo/RElQaRQP7w1v7UEMjyATUALH3lqI7uAN5S0furVpZKd GSRQ== 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=JqTdKTDdhhvQtZZBygtrOEZ/plp0svP5Se/zJYrh/p8=; b=YPLZeBDwURPxH22UAgKIVoO+3zCL4Gvtdl521LnK+ZvebjFz/vHRb49yxz0LHgpVh3 p0GkKOUxlMazm9GioveQr5MyNAsaytvR6HYfiwUGR19h45ab53RhB8+QP5aXC1ir0WuF P00WRZ+6oFrPWlykTRX2FtHlwwn3JblPsa/TPRbc17tj77WnUzV1BS7fAXYqJ6yIgxZp CaPGE7/Sc69n41GsNaUNlAY4rgS9w9vpHkNJt9i9bsNzVo+9PuVCihwlwGPdg/Ic4Sya 4p1udHlEAUOHerA2cBcfHzdbJ0M0Bcm1V6TYQ5DUY62Kmbo91VRV6AXUTgNCxBTzvFzR Qveg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oGzAxBql; 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 w135-20020a37628d000000b006af2669b0ffsi3562032qkb.187.2022.07.11.07.12.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jul 2022 07:12:37 -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=oGzAxBql; 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]:37710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oAu9N-0007bk-Cz for patch@linaro.org; Mon, 11 Jul 2022 10:12:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAtvW-0006aC-ID for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:19 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:36545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oAtvT-0002ri-J1 for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:18 -0400 Received: by mail-wr1-x429.google.com with SMTP id o4so7143027wrh.3 for ; Mon, 11 Jul 2022 06:58:14 -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=JqTdKTDdhhvQtZZBygtrOEZ/plp0svP5Se/zJYrh/p8=; b=oGzAxBqlp+PfV1WkV+Lxl0Zc9usZ34rz+JWUZOABf472hmZf5GfiDWvbTT0cYF7TAt zz9na2cRDkZrJ0UXFMJmKZnHXJHg2Er5zj8kJ4bsnM78u6dEzsBvYEkVGmcmTC9Usklk j3aroRfgXeJiKGT8wXy0TcIEQ52FJTU2lOfnFQECoVJ21tUTEi65O7aIWYUQ9kNlJ6qr /DQdNWTCMvdGs2h4HDBg1ubuZBVkJ6q7Z/Y7S+Szcy31OrXJsChX/03fFPUgXOelsEx2 byyWpHhH/H1KclCp6IZ5HFypwiiaeW55RWSPMDEL1IKpII4lLupy28MUheYndns2ETN7 K2/A== 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=JqTdKTDdhhvQtZZBygtrOEZ/plp0svP5Se/zJYrh/p8=; b=vlY/6LVq7So1v0O/9jUyZ4nBOYXVjhT9cbXF4ZkW1kwQtl995LOXJAi5rtYpg0bzA3 yrc5TG+67DrXU6zZcCe01VWeeuOfAsvQlJu7aMsxu8l40YxAw6wCHbVW+7ueriRrx4sK +WYd9kzDcGD8nz/vcfw6NdFSZtTrv/Ww4LYkL2PJHPSs8k3KfANafbTBaQNsmtbfYNYR nw9mv8jbhsdLYo0cr+h4Rs5iqImUmCWCMWtwFv9UiZD4pl7qTIu75EmF5tyv/2Uy7bWt aosueef5pA11vXUdhgwaBWXSx/QWdvtNpw9EYpcHVlDUgWjwxwFZYZvjNHOR+Q9tdAH2 zOZQ== X-Gm-Message-State: AJIora/an1Gq7tq2YU24pkNUOIM7/lgqtRg6aV4d07f4pFAV2zmoBcqa qVHlx3KpRfDB6fCZhQ03Y4D08cE3Bdnc/Q== X-Received: by 2002:adf:b613:0:b0:21d:6da6:d541 with SMTP id f19-20020adfb613000000b0021d6da6d541mr16666040wre.485.1657547893284; Mon, 11 Jul 2022 06:58:13 -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.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 06:58:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/45] target/arm: Implement BFMOPA, BFMOPS Date: Mon, 11 Jul 2022 14:57:30 +0100 Message-Id: <20220711135750.765803-26-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::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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 Signed-off-by: Richard Henderson Message-id: 20220708151540.18136-26-richard.henderson@linaro.org Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell --- target/arm/helper-sme.h | 2 ++ target/arm/sme.decode | 2 ++ target/arm/sme_helper.c | 56 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-sme.c | 30 ++++++++++++++++++++ 4 files changed, 90 insertions(+) diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h index f50d0fe1d62..1d68fb8c74f 100644 --- a/target/arm/helper-sme.h +++ b/target/arm/helper-sme.h @@ -125,3 +125,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.decode b/target/arm/sme.decode index ba4774d1746..afd9c0dffda 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 diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index 7dc76b6a1c3..690a53eee2d 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -987,3 +987,59 @@ void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn, } } } + +/* + * 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) +{ + /* + * The pseudocode uses a conditional negate after the conditional zero. + * It is simpler here to unconditionally negate before conditional zero. + */ + 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) * 0x80008000u; + uint16_t *pn = vpn, *pm = vpm; + + for (row = 0; row < oprsz; ) { + uint16_t prow = pn[H2(row >> 4)]; + do { + void *vza_row = vza + tile_vslice_offset(row); + uint32_t n = *(uint32_t *)(vzn + H1_4(row)); + + n = f16mop_adj_pair(n, prow, neg); + + for (col = 0; col < oprsz; ) { + uint16_t pcol = pm[H2(col >> 4)]; + do { + if (prow & pcol & 0b0101) { + uint32_t *a = vza_row + H1_4(col); + uint32_t m = *(uint32_t *)(vzm + H1_4(col)); + + m = f16mop_adj_pair(m, pcol, 0); + *a = bfdotadd(*a, n, m); + + col += 4; + pcol >>= 4; + } + } while (col & 15); + } + row += 4; + prow >>= 4; + } while (row & 15); + } +} diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c index fa8f343a7d6..ecb7583c559 100644 --- a/target/arm/translate-sme.c +++ b/target/arm/translate-sme.c @@ -299,6 +299,33 @@ 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) +{ + int svl = streaming_vec_reg_size(s); + uint32_t desc = simd_desc(svl, 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) { @@ -330,3 +357,6 @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, 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)