From patchwork Mon Jul 11 13:57:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 589383 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp3314648mab; Mon, 11 Jul 2022 07:49:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tFg6j1Bry4973mc1+5tL3+gPZ+6hOByH/iYYS7PVMScrkKGz8T3fF8u46RQ3H2yAO4JiU1 X-Received: by 2002:ad4:5f8a:0:b0:473:2108:7fe0 with SMTP id jp10-20020ad45f8a000000b0047321087fe0mr13728787qvb.115.1657550959975; Mon, 11 Jul 2022 07:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657550959; cv=none; d=google.com; s=arc-20160816; b=CHEOPwiRSrNR3SdSSBxECuAlx5ANUDqerbB+l+Y34LgBHSCUNQcdAyjxhsS5OKoK5T FUaH+mWU6k59Fqqzp4hLTwiBOGa/ySjnuBGNYg1Z6Ux4mzexcuygmFjQB2PpbIJI6H1G 44r3aBXifg/4FILYCsTeVoI0qPzs1zuK6j2NDBNwQWfAREuPqrh35FAAX9FLqc9fa/gg LyLmeAh56YLI5+wHuHY4Lax+oDQh2HOSP0sUYUQlOprE/wqMxJsWVfMV7K7vbH/OLhLa gzbonWE5Zr+aMQpp5dcW94K08xIW2cG2CyBboLeeITcxHdoXynEuT9GVCrKWCWn7djF7 vtpw== 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=cR0PvnQKG0XfbYb9xus9rRJ6s/0aSnCTWRG0QGmXr4w=; b=UlgJ/vqd6K26oOwuco0XrAsbD9u4RG1qBwHfyqrOmyiz6jmXSgSgSQQmDcaJSTOjl8 itUaZ7UalexnCCGODWiU7PxjhOX2zyI08xumujy5Xz88PdPsXke/VjLA0b+yl8fhU6g9 sVF5l7gkYtFUVUlDLEKfKKe/siIJAx1zsvThXotIKEONnIl5t5UkZnZ2Kl9g3S5RQpE9 m4qIA/+51Yw4JXbKwEb8Raq6yr89zXRCktRcvqqNB1xzevJZqDLC4iEIU9FckCEhsGnv AAFQs/x3ojc+aUw57pysi+XRO4ezf+8+TkNqv468CbkpxWvuoT5SC1IQapXlW+4ct9w5 WXIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iqQk8F2x; 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 v38-20020a05622a18a600b0031eaed115dasi4405798qtc.652.2022.07.11.07.49.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jul 2022 07:49:19 -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=iqQk8F2x; 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]:44238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oAuit-0003ki-Cu for patch@linaro.org; Mon, 11 Jul 2022 10:49:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAtvW-0006Zq-GM for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:19 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:53118) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oAtvT-0002rT-J9 for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:17 -0400 Received: by mail-wm1-x32e.google.com with SMTP id o8so3086158wms.2 for ; Mon, 11 Jul 2022 06:58:13 -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=cR0PvnQKG0XfbYb9xus9rRJ6s/0aSnCTWRG0QGmXr4w=; b=iqQk8F2xsaV4i1VVN7W8K8HT+bnzR5juzxYOwX7mbjXOcFONGHwSXCK2YoXACpUV+o y61yBqFqOT9fv9aL6Tsr0ofRC/LFnZCTujyi8i75I4WEN07hMkL8taxB80H57Bw8sDwJ czEJLY59sbyeW6aeXWVGN5Osruu29bIGXs0SgAMQMBmUbEkZJ+4aHpnoPxVx5pUKo3zt 7sfU9uz1aRbUHMlAveD6YJHqqGWJNGhtD4BDHc0DKNknIUpEty3F56F/byghLsgTB/mR MzCP/04LYmvX/N+UPHiB+0mVki8KmFXrPzN91cJM4LKFeFR+8od3JJOU0RZjLPOHrwiq 2KiQ== 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=cR0PvnQKG0XfbYb9xus9rRJ6s/0aSnCTWRG0QGmXr4w=; b=2fFQ6M0lSh1dM1Nn4bI+TNFQ2M1VEtvxxjpfjhHnLM6hQWbtpcLiS1YL24Jqs1FbmD QXqNfORd1utri6xnLf7hynYWIoHNwR9JNhSLHT4TAzg9lU1au6G4HbKQFAMPB5NDe7rN svUH80SH+I6Y4NoJmOIORj8+D3Fgf5gGW91avZZ7NZFihDD0rBxyg+MpEkULAZE66UEk ui8o97rEqwlAb6NqWcCQKQEoaLtK34UqFUrMTJtuiIN5GqCUng79gzJL3ZPZMWjwWgWg nR3hikwhPLWpwoHsaxkUdHuA10+Via/wqGFWAx13MWkbDwGDwc/SSWXkB42dZ9swjltp 9R4g== X-Gm-Message-State: AJIora+wxFnjac754fSolzwv6Sc5AeQVIfA5p14FiSf66ritd6T1jOQd 2q8FLqdu3kIjjqaj10mohU3NEg96B4dN0Q== X-Received: by 2002:a05:600c:42d3:b0:3a2:e7b8:8430 with SMTP id j19-20020a05600c42d300b003a2e7b88430mr6371997wme.42.1657547892517; Mon, 11 Jul 2022 06:58:12 -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:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/45] target/arm: Implement FMOPA, FMOPS (non-widening) Date: Mon, 11 Jul 2022 14:57:29 +0100 Message-Id: <20220711135750.765803-25-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::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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-25-richard.henderson@linaro.org Signed-off-by: Peter Maydell Reviewed-by: Peter Maydell --- target/arm/helper-sme.h | 5 +++ target/arm/sme.decode | 9 +++++ target/arm/sme_helper.c | 69 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-sme.c | 32 ++++++++++++++++++ 4 files changed, 115 insertions(+) diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h index 753e9e624cc..f50d0fe1d62 100644 --- a/target/arm/helper-sme.h +++ b/target/arm/helper-sme.h @@ -120,3 +120,8 @@ 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) + +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) diff --git a/target/arm/sme.decode b/target/arm/sme.decode index 8cb6c4053c3..ba4774d1746 100644 --- a/target/arm/sme.decode +++ b/target/arm/sme.decode @@ -64,3 +64,12 @@ 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 + +### SME Outer Product + +&op zad zn zm pm pn sub:bool +@op_32 ........ ... zm:5 pm:3 pn:3 zn:5 sub:1 .. zad:2 &op +@op_64 ........ ... zm:5 pm:3 pn:3 zn:5 sub:1 . zad:3 &op + +FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32 +FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64 diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index f1e924db748..7dc76b6a1c3 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -25,6 +25,7 @@ #include "exec/cpu_ldst.h" #include "exec/exec-all.h" #include "qemu/int128.h" +#include "fpu/softfloat.h" #include "vec_internal.h" #include "sve_ldst_internal.h" @@ -918,3 +919,71 @@ void HELPER(sme_addva_d)(void *vzda, void *vzn, void *vpn, } } } + +void HELPER(sme_fmopa_s)(void *vza, void *vzn, void *vzm, void *vpn, + void *vpm, void *vst, uint32_t desc) +{ + intptr_t row, col, oprsz = simd_maxsz(desc); + uint32_t neg = simd_data(desc) << 31; + uint16_t *pn = vpn, *pm = vpm; + float_status fpst; + + /* + * Make a copy of float_status because this operation does not + * update the cumulative fp exception status. It also produces + * default nans. + */ + fpst = *(float_status *)vst; + set_default_nan_mode(true, &fpst); + + for (row = 0; row < oprsz; ) { + uint16_t pa = pn[H2(row >> 4)]; + do { + if (pa & 1) { + void *vza_row = vza + tile_vslice_offset(row); + uint32_t n = *(uint32_t *)(vzn + H1_4(row)) ^ neg; + + for (col = 0; col < oprsz; ) { + uint16_t pb = pm[H2(col >> 4)]; + do { + if (pb & 1) { + uint32_t *a = vza_row + H1_4(col); + uint32_t *m = vzm + H1_4(col); + *a = float32_muladd(n, *m, *a, 0, vst); + } + col += 4; + pb >>= 4; + } while (col & 15); + } + } + row += 4; + pa >>= 4; + } while (row & 15); + } +} + +void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn, + void *vpm, void *vst, uint32_t desc) +{ + intptr_t row, col, oprsz = simd_oprsz(desc) / 8; + uint64_t neg = (uint64_t)simd_data(desc) << 63; + uint64_t *za = vza, *zn = vzn, *zm = vzm; + uint8_t *pn = vpn, *pm = vpm; + float_status fpst = *(float_status *)vst; + + set_default_nan_mode(true, &fpst); + + for (row = 0; row < oprsz; ++row) { + if (pn[H1(row)] & 1) { + uint64_t *za_row = &za[tile_vslice_index(row)]; + uint64_t n = zn[row] ^ neg; + + for (col = 0; col < oprsz; ++col) { + if (pm[H1(col)] & 1) { + uint64_t *a = &za_row[col]; + *a = float64_muladd(n, zm[col], *a, 0, &fpst); + } + } + } + } +} diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c index d3b9cdd5c4b..fa8f343a7d6 100644 --- a/target/arm/translate-sme.c +++ b/target/arm/translate-sme.c @@ -298,3 +298,35 @@ 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) + +static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, + gen_helper_gvec_5_ptr *fn) +{ + int svl = streaming_vec_reg_size(s); + uint32_t desc = simd_desc(svl, svl, a->sub); + TCGv_ptr za, zn, zm, pn, pm, fpst; + + 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); + fpst = fpstatus_ptr(FPST_FPCR); + + fn(za, zn, zm, pn, pm, fpst, tcg_constant_i32(desc)); + + tcg_temp_free_ptr(za); + tcg_temp_free_ptr(zn); + tcg_temp_free_ptr(pn); + tcg_temp_free_ptr(pm); + tcg_temp_free_ptr(fpst); + return true; +} + +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)