From patchwork Thu Jun 21 01:53:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 139406 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1471058lji; Wed, 20 Jun 2018 18:58:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJQz4fEj4l7niEOOURUK9w9O6FR23Ev+2LY93SwxeJE4iFyMOud+RT/Ten6FvOsAMt8EuPi X-Received: by 2002:a0c:e354:: with SMTP id a20-v6mr20455376qvm.229.1529546337481; Wed, 20 Jun 2018 18:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529546337; cv=none; d=google.com; s=arc-20160816; b=0PU6o34NTJKuEm5uEmQ5NMVTI0XCCMp5TrFrzvgN9ASyfgJcgdTAzlGOVu124xn4bF /w0vyc2JTI1azbxds0Xz4dzNVkAcpsB7s3A+JPXhjZ0dmgMlgRjNkD604eXFJG4vSsP9 D5SyhLYc6EmdPX8E2a2oNN/QZ1zS9GgLD75CXp7/1VH5fgGD0zsB1h6wstxxNAibPKQQ jzQtHMMLoSdYhOXPXXu5DHjwYFbT+Pt9bQB3o08TuB6ahAwwSbRMKpM90SlFB7SKRUK1 rRS6QTSgK96RjX03LbgyvM6vbLBkZYy3oaF8NcPY09F7AmrquNK+j2p30y9YpwAd4DLK JOCQ== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=zMUCpNHqvYI8Hwem4/9P2JgKC2kBIp0MNfhRl9e2Emo=; b=r96DnxjiR+pNJSN98NEfpmUkPX0JSqKVwxOre758v5By+nuLy1+jKDYS9Ro800wviZ kz7qL7MUd79kNzS3189b14e2Hf2DWvvJTjQLF7rG7a69L1rS4HBOu1Vwz9jHDWTQZyUx 8I7Jb1I5fp1A89IC5r7cctQIfxvShudNLBCr+mEO1J+kv5gYiSeLmhB5COvXdwYIBp7C lCpXo3TZF6XEsxco/g+LO8+URn6Df3Ltzl/tUiNS6YPg+tJ5hnbJ8lU5trQYnRmWFid0 UsztD4g64Uvmz/RKs8MDzR8aqy79YdF7LiEq00O3MQBtL983D8QMllGQ3q1pziXXkt58 Oerg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="X0b2Xv/f"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l190-v6si508433qkf.37.2018.06.20.18.58.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Jun 2018 18:58:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="X0b2Xv/f"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:52498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVosC-0007T3-UW for patch@linaro.org; Wed, 20 Jun 2018 21:58:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVonn-00047F-7A for qemu-devel@nongnu.org; Wed, 20 Jun 2018 21:54:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVonm-00032y-4S for qemu-devel@nongnu.org; Wed, 20 Jun 2018 21:54:23 -0400 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]:46298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVonl-00032b-Sf for qemu-devel@nongnu.org; Wed, 20 Jun 2018 21:54:22 -0400 Received: by mail-pf0-x22a.google.com with SMTP id q1-v6so676563pff.13 for ; Wed, 20 Jun 2018 18:54:21 -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; bh=zMUCpNHqvYI8Hwem4/9P2JgKC2kBIp0MNfhRl9e2Emo=; b=X0b2Xv/fpekxUwxARyRF5KM/iKI9DXWj/G0sK9mxEnRpfsERL0kh83FaCzqp4z+sKQ KfvUWm5n2SzFpI39LhkHWYRGIj2cNsiy8fScfv5rQ+C2tzgJ+6AwafZ9ZMZ9l6lMwfbO W+p+pcm8loYraOlmOF/RjtWlZBFq2AVdT4JRw= 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; bh=zMUCpNHqvYI8Hwem4/9P2JgKC2kBIp0MNfhRl9e2Emo=; b=gY38APSSvgRPFZ+uf6eBbeve6M3FkzbUHsLP4JaBp3fx29tzXJf2G2PoassXojLrAS YgiiqkVElk/gW2E/ura9D5W5G3vlz4AaA4qEebTjgXyHUdh9bZ1ikT7bOOArAmUoUCUM 6M0wMa0ugtrR4qfV4Pmx5NTjJgE6W7DOZSUG34w8dFfJXGlkSmRqafmZLyNnK5xToDEZ jon4TkfrROts5sbim6Lx8I6T5yQ0rF0TZUTor8xzVqpV53GNUUXkpJjtFMfOHORXsmFO sef2Z/iVgLW4jAmDXCopziPa76zmFRtOHUAmsn7McrunxRS9XiRZ/iuubrfxImj0PMpL 2Vtw== X-Gm-Message-State: APt69E3px0yhOWojsMyQHKK3L2QITz8drR4vjMBzjKHYFRi4OzCM0zMo Mthi2UpRzGCf9Xi95W1RrXExfxIEouI= X-Received: by 2002:a65:65ca:: with SMTP id y10-v6mr20821260pgv.359.1529546060529; Wed, 20 Jun 2018 18:54:20 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id a27-v6sm6187946pfc.18.2018.06.20.18.54.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 18:54:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 20 Jun 2018 15:53:32 -1000 Message-Id: <20180621015359.12018-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180621015359.12018-1-richard.henderson@linaro.org> References: <20180621015359.12018-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22a Subject: [Qemu-devel] [PATCH v5 08/35] target/arm: Implement SVE Floating Point Accumulating Reduction Group X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper-sve.h | 7 +++++ target/arm/sve_helper.c | 56 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-sve.c | 45 ++++++++++++++++++++++++++++++ target/arm/sve.decode | 5 ++++ 4 files changed, 113 insertions(+) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index eb0645dd43..68e55a8d03 100644 --- a/target/arm/helper-sve.h +++ b/target/arm/helper-sve.h @@ -720,6 +720,13 @@ DEF_HELPER_FLAGS_5(gvec_rsqrts_s, TCG_CALL_NO_RWG, DEF_HELPER_FLAGS_5(gvec_rsqrts_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_fadda_h, TCG_CALL_NO_RWG, + i64, i64, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_fadda_s, TCG_CALL_NO_RWG, + i64, i64, ptr, ptr, ptr, i32) +DEF_HELPER_FLAGS_5(sve_fadda_d, TCG_CALL_NO_RWG, + i64, i64, ptr, ptr, ptr, i32) + DEF_HELPER_FLAGS_6(sve_fadd_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_6(sve_fadd_s, TCG_CALL_NO_RWG, diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index aeb4ccadd9..990e5f3900 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -2811,6 +2811,62 @@ uint32_t HELPER(sve_while)(void *vd, uint32_t count, uint32_t pred_desc) return predtest_ones(d, oprsz, esz_mask); } +uint64_t HELPER(sve_fadda_h)(uint64_t nn, void *vm, void *vg, + void *status, uint32_t desc) +{ + intptr_t i = 0, opr_sz = simd_oprsz(desc); + float16 result = nn; + + do { + uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); + do { + if (pg & 1) { + float16 mm = *(float16 *)(vm + H1_2(i)); + result = float16_add(result, mm, status); + } + i += sizeof(float16), pg >>= sizeof(float16); + } while (i & 15); + } while (i < opr_sz); + + return result; +} + +uint64_t HELPER(sve_fadda_s)(uint64_t nn, void *vm, void *vg, + void *status, uint32_t desc) +{ + intptr_t i = 0, opr_sz = simd_oprsz(desc); + float32 result = nn; + + do { + uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); + do { + if (pg & 1) { + float32 mm = *(float32 *)(vm + H1_2(i)); + result = float32_add(result, mm, status); + } + i += sizeof(float32), pg >>= sizeof(float32); + } while (i & 15); + } while (i < opr_sz); + + return result; +} + +uint64_t HELPER(sve_fadda_d)(uint64_t nn, void *vm, void *vg, + void *status, uint32_t desc) +{ + intptr_t i = 0, opr_sz = simd_oprsz(desc) / 8; + uint64_t *m = vm; + uint8_t *pg = vg; + + for (i = 0; i < opr_sz; i++) { + if (pg[H1(i)] & 1) { + nn = float64_add(nn, m[i], status); + } + } + + return nn; +} + /* Fully general three-operand expander, controlled by a predicate, * With the extra float_status parameter. */ diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index acad6374ef..483ad33179 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -3383,6 +3383,51 @@ DO_ZZI(UMIN, umin) #undef DO_ZZI +/* + *** SVE Floating Point Accumulating Reduction Group + */ + +static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a, uint32_t insn) +{ + typedef void fadda_fn(TCGv_i64, TCGv_i64, TCGv_ptr, + TCGv_ptr, TCGv_ptr, TCGv_i32); + static fadda_fn * const fns[3] = { + gen_helper_sve_fadda_h, + gen_helper_sve_fadda_s, + gen_helper_sve_fadda_d, + }; + unsigned vsz = vec_full_reg_size(s); + TCGv_ptr t_rm, t_pg, t_fpst; + TCGv_i64 t_val; + TCGv_i32 t_desc; + + if (a->esz == 0) { + return false; + } + if (!sve_access_check(s)) { + return true; + } + + t_val = load_esz(cpu_env, vec_reg_offset(s, a->rn, 0, a->esz), a->esz); + t_rm = tcg_temp_new_ptr(); + t_pg = tcg_temp_new_ptr(); + tcg_gen_addi_ptr(t_rm, cpu_env, vec_full_reg_offset(s, a->rm)); + tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, a->pg)); + t_fpst = get_fpstatus_ptr(a->esz == MO_16); + t_desc = tcg_const_i32(simd_desc(vsz, vsz, 0)); + + fns[a->esz - 1](t_val, t_val, t_rm, t_pg, t_fpst, t_desc); + + tcg_temp_free_i32(t_desc); + tcg_temp_free_ptr(t_fpst); + tcg_temp_free_ptr(t_pg); + tcg_temp_free_ptr(t_rm); + + write_fp_dreg(s, a->rd, t_val); + tcg_temp_free_i64(t_val); + return true; +} + /* *** SVE Floating Point Arithmetic - Unpredicated Group */ diff --git a/target/arm/sve.decode b/target/arm/sve.decode index 70e5a3aeb5..ba10cddb8a 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -676,6 +676,11 @@ UMIN_zzi 00100101 .. 101 011 110 ........ ..... @rdn_i8u # SVE integer multiply immediate (unpredicated) MUL_zzi 00100101 .. 110 000 110 ........ ..... @rdn_i8s +### SVE FP Accumulating Reduction Group + +# SVE floating-point serial reduction (predicated) +FADDA 01100101 .. 011 000 001 ... ..... ..... @rdn_pg_rm + ### SVE Floating Point Arithmetic - Unpredicated Group # SVE floating-point arithmetic (unpredicated)