From patchwork Tue May 25 01:02:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 447088 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp3819016jac; Mon, 24 May 2021 18:22:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjqF/Dlh8C2ECWUYKCUTzfBn3RjeDCHmP5QltqDn3o8cU8lbswvTD+FWZniriscQjXr5NS X-Received: by 2002:a0c:fd44:: with SMTP id j4mr33647840qvs.12.1621905752798; Mon, 24 May 2021 18:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621905752; cv=none; d=google.com; s=arc-20160816; b=ozcIsGCYuMRi6pm2VZ2RG9z3J38szjdCW1jpGs4fhRKe/mEsOyPI+7FMJdObsP1gOb G46J1kgAtQBhYrW2AYERVPNelRcBLzB36PgkeyO9+NR2ifEBIWsMFNVQGdrTXMA+mQRo pyp3VhBb7IaNk/I3GSOZmLm4VBwA4xJPzXmpH1fhVmcZ28bN+9CTxVewbYJmfyuRfQk8 uv4XY25vEjHhd1FL/hbMCq5dmJnyFeXdvmGqxKW3JbR01/7gDjqxQFkfNMmFb9IOqPyl DKRBC4VNhlxO10EfAUC/boUsmGui06b2O67ELV1HvRp7PQanm4QGmt5luej+3KiDj16V +AvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=SWFfFR452q1fUmRFJ3PaFSu6DwY4BPwjHHMIRk/NZbA=; b=BgNCrmmpE/sU9u45tcFpzCFm7tsA7Zh5cZWgIfDf2fB08owlsfzAhh7f3c7RIxkEDy u9hiwKrXMBWGVH9mLR+tXUX3ZLYrfFqFiYjGBuiCJ/BAwJwroPoK77VDxlzfOxM86lh0 rcnGGeaTXnrNA5bxsCXH6UQ8MEsRSy6zYEBXTqAQiWDnF9Rrw5yXe1IOnCnlObczyRgb 1u8gFbgACjQ8PSqgtRb+ZtkfrtwLzPdNrv49EJmZP2TgGPDib6RRBZmMxwDKZIoMDMQG Ig1+E3ix4K+cFah1MIN0pczoK4U3qQ1JAxya7acfIetPV7RwfT5ko5UkvIDmtZUUVxXn gcNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eoEgxpve; 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=fail (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 a5si10274041qkk.341.2021.05.24.18.22.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 May 2021 18:22:32 -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=fail header.i=@linaro.org header.s=google header.b=eoEgxpve; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llLmC-0006jI-6G for patch@linaro.org; Mon, 24 May 2021 21:22:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llLUn-0001se-Ry for qemu-devel@nongnu.org; Mon, 24 May 2021 21:04:36 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:55840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llLUT-0001mp-AX for qemu-devel@nongnu.org; Mon, 24 May 2021 21:04:33 -0400 Received: by mail-pj1-x1030.google.com with SMTP id kr9so7794900pjb.5 for ; Mon, 24 May 2021 18:04:12 -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=SWFfFR452q1fUmRFJ3PaFSu6DwY4BPwjHHMIRk/NZbA=; b=eoEgxpve4A8zngVkaQB3BqKjCLq/mqS6llMMuYGnp5guFpLPbERF0f4lODQ5gZxUDO yOXSImBamWY36CwkUDixipcX3FwxXR9wiq07Id40SRxv02Ey7NnB4MfoqgJRtaEHMO9u hJ5/gq2L0aFxQD2/Hh7q65Mqe3S4HiwFemILsvoxjOXlfOgf1cFhH9qH8PgGT1ap2dQM fDNX/df2OHWnaGJibDhjkhiCpLM+hikV8GudqTluRY1V2aGJNGzd0cAakhQ64goEw7pv yLnGJhT89VeGrMGKPIA27MoOUEWhYzStQK+5HxNYoqb4mJ4IigdEBsXt18C2EOFSwoqV thRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SWFfFR452q1fUmRFJ3PaFSu6DwY4BPwjHHMIRk/NZbA=; b=LkQ8PiUQ/Bg+ZsM4uUJWx8lrXBiZYFXMdiatI5XBceQBLZqXA6BNuON16UqVwn0M+z F0YtYy1tp2nfE29VcawOHN9Dk+SVprM/OE5cjZf0H0pRT4ga7WXi05RDtO3K2yC4WlCS 88JSx4z6saTcwpES8NAN1IXV0iZgZvDb+HsGY86y2VLAOqxvXzlawGE78oDgS/Ry1K2Z MRwjNjzSxN128LI3Zs35P85Fwv6vNoweoqMRiRtFrHZ41xO66LN7MtB9uO1FU9CMtAEQ qreJhfWwS/gUqYC/NqQ6XXPfAsIEbHuHA5Y3o4rjyrEzq2rvXUN0YH5U9OT1q1PlwCTW tF3Q== X-Gm-Message-State: AOAM532jQ8UiQoUg5M9udQBuyM82cKzbMVdKRjPyhLX1JQ4UXFqXWcRP Gu3cbdUCfhtFd0hZOd0ezctNPQ4VtOrD9g== X-Received: by 2002:a17:90b:4d82:: with SMTP id oj2mr27258073pjb.61.1621904651960; Mon, 24 May 2021 18:04:11 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id b1sm13742645pgf.84.2021.05.24.18.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 18:04:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 20/92] target/arm: Implement SVE2 integer add/subtract long with carry Date: Mon, 24 May 2021 18:02:46 -0700 Message-Id: <20210525010358.152808-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525010358.152808-1-richard.henderson@linaro.org> References: <20210525010358.152808-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v2: Fix sel indexing and argument order (laurent desnogues). --- target/arm/helper-sve.h | 3 +++ target/arm/sve.decode | 6 ++++++ target/arm/sve_helper.c | 34 ++++++++++++++++++++++++++++++++++ target/arm/translate-sve.c | 23 +++++++++++++++++++++++ 4 files changed, 66 insertions(+) -- 2.25.1 diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index 229fb396b2..4a62012850 100644 --- a/target/arm/helper-sve.h +++ b/target/arm/helper-sve.h @@ -2416,3 +2416,6 @@ DEF_HELPER_FLAGS_5(sve2_uabal_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve2_uabal_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) + +DEF_HELPER_FLAGS_5(sve2_adcl_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve2_adcl_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) diff --git a/target/arm/sve.decode b/target/arm/sve.decode index 56b7353bfa..79046d81e3 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -1247,3 +1247,9 @@ SABALB 01000101 .. 0 ..... 1100 00 ..... ..... @rda_rn_rm SABALT 01000101 .. 0 ..... 1100 01 ..... ..... @rda_rn_rm UABALB 01000101 .. 0 ..... 1100 10 ..... ..... @rda_rn_rm UABALT 01000101 .. 0 ..... 1100 11 ..... ..... @rda_rn_rm + +## SVE2 integer add/subtract long with carry + +# ADC and SBC decoded via size in helper dispatch. +ADCLB 01000101 .. 0 ..... 11010 0 ..... ..... @rda_rn_rm +ADCLT 01000101 .. 0 ..... 11010 1 ..... ..... @rda_rn_rm diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 5d084a1164..b63d84eef4 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -1269,6 +1269,40 @@ DO_ZZZW_ACC(sve2_uabal_d, uint64_t, uint32_t, , H1_4, DO_ABD) #undef DO_ZZZW_ACC +void HELPER(sve2_adcl_s)(void *vd, void *vn, void *vm, void *va, uint32_t desc) +{ + intptr_t i, opr_sz = simd_oprsz(desc); + int sel = H4(extract32(desc, SIMD_DATA_SHIFT, 1)); + uint32_t inv = -extract32(desc, SIMD_DATA_SHIFT + 1, 1); + uint32_t *a = va, *n = vn; + uint64_t *d = vd, *m = vm; + + for (i = 0; i < opr_sz / 8; ++i) { + uint32_t e1 = a[2 * i + H4(0)]; + uint32_t e2 = n[2 * i + sel] ^ inv; + uint64_t c = extract64(m[i], 32, 1); + /* Compute and store the entire 33-bit result at once. */ + d[i] = c + e1 + e2; + } +} + +void HELPER(sve2_adcl_d)(void *vd, void *vn, void *vm, void *va, uint32_t desc) +{ + intptr_t i, opr_sz = simd_oprsz(desc); + int sel = extract32(desc, SIMD_DATA_SHIFT, 1); + uint64_t inv = -(uint64_t)extract32(desc, SIMD_DATA_SHIFT + 1, 1); + uint64_t *d = vd, *a = va, *n = vn, *m = vm; + + for (i = 0; i < opr_sz / 8; i += 2) { + Int128 e1 = int128_make64(a[i]); + Int128 e2 = int128_make64(n[i + sel] ^ inv); + Int128 c = int128_make64(m[i + 1] & 1); + Int128 r = int128_add(int128_add(e1, e2), c); + d[i + 0] = int128_getlo(r); + d[i + 1] = int128_gethi(r); + } +} + #define DO_BITPERM(NAME, TYPE, OP) \ void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \ { \ diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index c41464ba22..cf4fa50ad2 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -6371,3 +6371,26 @@ static bool trans_UABALT(DisasContext *s, arg_rrrr_esz *a) { return do_abal(s, a, true, true); } + +static bool do_adcl(DisasContext *s, arg_rrrr_esz *a, bool sel) +{ + static gen_helper_gvec_4 * const fns[2] = { + gen_helper_sve2_adcl_s, + gen_helper_sve2_adcl_d, + }; + /* + * Note that in this case the ESZ field encodes both size and sign. + * Split out 'subtract' into bit 1 of the data field for the helper. + */ + return do_sve2_zzzz_ool(s, a, fns[a->esz & 1], (a->esz & 2) | sel); +} + +static bool trans_ADCLB(DisasContext *s, arg_rrrr_esz *a) +{ + return do_adcl(s, a, false); +} + +static bool trans_ADCLT(DisasContext *s, arg_rrrr_esz *a) +{ + return do_adcl(s, a, true); +}