From patchwork Tue Mar 9 16:19:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 396018 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2769790jai; Tue, 9 Mar 2021 09:23:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYMhTpJ1pIaYzto8bdAEfqSKQHzW5fH/1LdZRjmyqSrHZdyxQmPCOMmO2nGbu28JSFRIz0 X-Received: by 2002:a1f:a692:: with SMTP id p140mr17491252vke.0.1615310627589; Tue, 09 Mar 2021 09:23:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615310627; cv=none; d=google.com; s=arc-20160816; b=KyN/T6pML4pcmS8zwCP5qu6gu4LJa31sG38naM4719ddBr0AAlypbiQ90rqKBIJgTz Ml+FJVGwqpqXSu5uH1AuBTI8ZSGHLanAeXeQe/be/00waGn7XnNlzVgjbgTXaAZoBvaq Yu4o+y4hP/kuGgW9+MrAh8dLz1fKJxVlp34AbcvoMmbaJrcMHflXf0maNFnSLT1Ie6ia POzNyUNdUaxaoT1VO29FeCFJOgQ0u3j1QtdtP6qNXdYIvXPgNghgkqIAU3IxU5f46ETT /o68ljtkynTl9FFDMykQ7opY+KIRR/zfnfHeSuQ+5ywkJAahXi1Vp+qzy29j/+VNcHt+ rgNQ== 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=OB55iI1IUo2lwcmr8zS27hEcvopOYX8FmeGTqkG2if0=; b=KDNFGV024Q95BHMqGnrHqjK1r54s1lWU24nD3tfctEbIyWv+YOrZN2pAqq/M+1w6FZ qm/fY2hzhf0Qh7dSnsnAlmO8xJoHqrnfBeoTk4nwipobel64rclrjHulIY2S0b7KRmEG Ukb5XN/h4RY/nTx5gPVYfR2KRLBMDmI30FXo4rwLfO77HBmyLK1eer1lHPm7FcDdpDSH 1m5yYPmiSNbv1Tc4hd/G8NCbB1hBkkG9NxvCVh3iEt6s2EmQz9mje52aiWoJoHlZrxrJ ppdY911rb78XmyDVBKNhZXrA4ThA4V+y8nof8+egG30REMZkT67KJ0d0w7lPiknT5ydS Ohzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FTpfUFX6; 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 v6si2601909vsl.189.2021.03.09.09.23.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Mar 2021 09:23:47 -0800 (PST) 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=FTpfUFX6; 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]:36890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJg5B-00051C-TD for patch@linaro.org; Tue, 09 Mar 2021 12:23:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJf6r-0007Nl-I8 for qemu-devel@nongnu.org; Tue, 09 Mar 2021 11:21:27 -0500 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]:40393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJf6Z-0002TH-SH for qemu-devel@nongnu.org; Tue, 09 Mar 2021 11:21:25 -0500 Received: by mail-oi1-x22e.google.com with SMTP id w65so15514542oie.7 for ; Tue, 09 Mar 2021 08:21:06 -0800 (PST) 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=OB55iI1IUo2lwcmr8zS27hEcvopOYX8FmeGTqkG2if0=; b=FTpfUFX6nSlrAv862BSzH6bjrB1HSO5Uj33nOwgkVsqVbH6StlKBUxxqXK+MwbfC2r sR8Ptu3bcnPSbjQG8D5IcPLETGsHJsIDkRaNY8040OUr4GurLi/QXuyIgIOG0hjlGgBo r0RdOLfW7R6Ab/XRgzam5JxQs2s/IQLvvXZSwNA1OoXgQjdEGIzXdHoxLmr2ebgtVsTm FEioWmFuzOz5tt1VYqcKntEht44gg27NvhvNT35pMQkdJUmgUT+T4fcRYVB6SqUX7M90 whkC4jCIvg6heG8p6epKQt0elS04JD1roevKe+x2r/YYKQXAEQE1HgtumOUPQbjxea2R TEAQ== 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=OB55iI1IUo2lwcmr8zS27hEcvopOYX8FmeGTqkG2if0=; b=ZwxzLaR2LfL4B+XaGwNBmZJtOaBe65bY7GOZcSkwSPHG9ZvM9gHeAMRC54RUwF3JZ4 EJAn4Y+Iw7Xt9/dhJgaMyMrG3imqZjeyk4VKco0IQFxfpjKevF4xftwdQOmmp3HT3Ptd MzvQp15dzdpAMP+MbsGUmldXp7jfxCOPksx2B8IG7ywF8quzI8Wr710bjj6Pr/a6uzyA XzJNM7IFoVNR+kN+oufIvSjyEXZSC87yBie2Pxa5jP24hxf9QZIgnzqyW0dIrTYDvO8w IF44+iAOFdDdgAGETKbq6p6AaOWki5rR/I0jcyNdmGtV+sXrheMAg85nYSSpNyDrHZPs SIhA== X-Gm-Message-State: AOAM530EsWAmr1wiAQuvP0dDsivfeFvyufLvTgAshDT/IcT49++N4qQ1 Z8KMVPYsHkzjINatkiImPW5SyN6EXSgKyTij X-Received: by 2002:aca:f3d6:: with SMTP id r205mr3643357oih.48.1615306865567; Tue, 09 Mar 2021 08:21:05 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id v23sm2516474ots.63.2021.03.09.08.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 08:21:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 20/78] target/arm: Implement SVE2 integer add/subtract long with carry Date: Tue, 9 Mar 2021 08:19:43 -0800 Message-Id: <20210309162041.23124-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210309162041.23124-1-richard.henderson@linaro.org> References: <20210309162041.23124-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22e.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@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.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 dd2c6a7404..aea04a60fd 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 c179e1f123..92420d3ec7 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -6372,3 +6372,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); +}