From patchwork Fri Apr 16 21:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 422610 Delivered-To: patch@linaro.org Received: by 2002:a02:6a6f:0:0:0:0:0 with SMTP id m47csp727078jaf; Fri, 16 Apr 2021 14:19:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7HvBdh1pMDmtTvpZVa1PtdaxMP4kfFFZnoTUKaMBLt4o0pJXRQ++/m4HBHhykOydpHjNe X-Received: by 2002:a5d:93da:: with SMTP id j26mr4965417ioo.6.1618607950673; Fri, 16 Apr 2021 14:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618607950; cv=none; d=google.com; s=arc-20160816; b=Fxd3S5er7uLiUS2bWy99D+SRz/4vqs99uRnY8FAUiNVlOWv2027jHT5lcPLZX3WMlT FwJLFiFfHruvLeJ3JjwzR7HN91gKMDURpdKoVoPzE7sJhxxhVDJeV6I0LEtFc5O7T2OT PK5PIPGDE7rGKL80w6Y31PhlchlWz5v3rPYB5tuosmhU+SWPhhcrthkFEjAE5AWcxPE6 rYvC/bJWQ0KqsrxdrsSL/DaQcHodT8dTYboxHjRuA6QhV49KTLsbgUUo95d+ij0GK2jz lWoxjWTWCIL9WjptLyfvtY3BguQfnIXL9YPn9CD36LjjuJHeUPO8Hn4ffFEdxdMLmulk 8qiQ== 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=1T/TF/O8cuPuJru/dQDvvvNN7AjjLNborpcatweuNPQ=; b=lCtogVYeJpGc0nDtRHlb9AnjQJug7jbsGN+AhNldV+cHQWNpqru3n9idiDec3D1+n2 dntz6mm0WrYhd8rlMm52brHv0/FgyECvEVqFMB4tYQ5gQG0Svj6r9fBd0SSZPXEA7UJS NtBAw2cpfHIrG0iVKmm3EGYz/RKpt2s/NHFrZ1TeKc6eBCaeU4jKHGQ1KJ3kYOxN9oWn 4uAorRRAXGrqqiqkUNZfqyJ/6QP9yyu9p0H9AJEGGP5dS5ZUE+6egxiI7ny1+T1krMsp KIwqxoVAKayfqZUko5YK9DXUeNYH7PsJZd02vRjyiIK8o/wKp1FAjkFl7WkiH2lcESe0 fyTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JThQJHw3; 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 d18si6673320ilo.12.2021.04.16.14.19.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Apr 2021 14:19: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=JThQJHw3; 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]:60528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXVrq-0007WM-1d for patch@linaro.org; Fri, 16 Apr 2021 17:19:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXVcL-0004KO-NS for qemu-devel@nongnu.org; Fri, 16 Apr 2021 17:03:09 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:41942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lXVcF-00019v-Gi for qemu-devel@nongnu.org; Fri, 16 Apr 2021 17:03:09 -0400 Received: by mail-pj1-x1031.google.com with SMTP id z22-20020a17090a0156b029014d4056663fso15283660pje.0 for ; Fri, 16 Apr 2021 14:03:03 -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=1T/TF/O8cuPuJru/dQDvvvNN7AjjLNborpcatweuNPQ=; b=JThQJHw3wCliuBpXdlhpX5L1AOTApBlNGYhRutedNhaFVjOBGBn1uN3iV4aOTIms1M Z8NCJjOs8uYK+cLmJJt/H7+jXVU9g4pCXZ5m844FUXbfy7omf2ZkL/a8w/WqjKvQ1TYL /cWwZH530MWkk8foCqHGm1F1QCzrY4XZkUPOhuQ3wFjAZ/CB6cWvRPos4H6pmzCdtGhF HjMj2jnwWlrGVKzV8eyUi+mzifQjxTpr/O1/qt3NO8Y61IdH4U2fbbNaiaLj/FJ2P52M pXVVWPdx0VKv0BZs3SVa91Sxix/vQb0NOIzUUAE97BVZZ9+SRnmFDIpARYIVGglwTrlF TPMw== 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=1T/TF/O8cuPuJru/dQDvvvNN7AjjLNborpcatweuNPQ=; b=lMriHvbAgDvwHRi/EQG4XEVRi8sco1Tx9rY4P4GK7r7X5nQoDlERMNsRiSgx2ZVk+4 cvhXVs8DNoxjS8P54SZcp+p9p3xviTjsdeEAHGqTwtnOKTf0k/b9eGOQ38+p4CP5iIv5 49OIEchmqOFJWVzN/6VOPC0zlaJGkpqgM7aVat3ji0J6VhCInRvQizlO1K4fKDN6RCCY i6cbxuxoewr7/YXVlp1TY1HH4FesBHM3Ze/bobNM31p+Vd9P2xjr3XpQM4v707JABv1V ef2aa4VEHj659OgXbHKBDDzcIqprbXlIW65RmsTxGBQg7GXzJhBpXH2yu7Em2Gh+SeC5 Aw0g== X-Gm-Message-State: AOAM532kwopZLr/5nS6MDU7LlxWROjTZlPVy3inTCQlD/3R88srMlmkg 6DVldQYHcrWigurFpvIwNTBj5Lqp+JREmw== X-Received: by 2002:a17:902:7581:b029:e7:3780:3c5f with SMTP id j1-20020a1709027581b02900e737803c5fmr11426665pll.59.1618606982237; Fri, 16 Apr 2021 14:03:02 -0700 (PDT) Received: from localhost.localdomain ([71.212.131.83]) by smtp.gmail.com with ESMTPSA id m15sm5920640pjz.36.2021.04.16.14.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Apr 2021 14:03:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 20/81] target/arm: Implement SVE2 integer add/subtract long with carry Date: Fri, 16 Apr 2021 14:01:39 -0700 Message-Id: <20210416210240.1591291-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210416210240.1591291-1-richard.henderson@linaro.org> References: <20210416210240.1591291-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 4871e90d9b..0049ad861f 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -1264,6 +1264,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 6ac50fd61f..6f5e39b741 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); +}