From patchwork Wed Jun 27 04:33:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 140100 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp389279ljj; Tue, 26 Jun 2018 21:43:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfRM/WkniBr5O5qvnbnBJ1ASr9nVzliUgBGQrw619heT9jWvzUBK61c0Xbaii6v89LcxrhU X-Received: by 2002:ac8:3885:: with SMTP id f5-v6mr4098364qtc.337.1530074630577; Tue, 26 Jun 2018 21:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530074630; cv=none; d=google.com; s=arc-20160816; b=CgBa0x5IJkxDmdx9y+WjwgspaJ3r6pc3fZHJac6uS9FE27l2kcY8BLU+/aTNMzrAKG yqQps8qmreNj0Do0Hj3cKgzkeBuXqUBoPGrWL9NXDOZHi9U+NZZN9R+/yN0pLQ9GTo8D NHtAyIicVMLlAycIUf9xOAd13nuzMV6eAqTbCuVk08MS//3xoQDpI0OIq4PO8iquqR/Z Zv71w9AC393JER4YaYBdI4z3v2U2FpJoqTvjq4rgDgKRbrCS3ad5JoIz5EOhEeTsPJqv YvqBQOr9f8/uSi6hWwwG5vZ8UlLIASbDQQ3ea1QHieFECbFXdoPt+bRxn5lUYV6SDeaa s+DA== 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=iG8HT096URRb4CWAiRTwQ1cVUSLxVdPPA37onBhzXoI=; b=pI3kIoXij9/2WiRIRIO2e+KcdeeIG4eiszi/uA+JLJNT0syUBYPPGio5KuLnGnPdYN yX4RMYkHU2TelYphr2NxDvUUY/+ZhAV+Z898Vra4FKirU1KiZmBW78eFDIOPVuvraM28 7hSlat3awNtUzsKDdKBsp4/PynGRyVz9vymaCOiJN/tniWBY7Z6nFbeEoRtASaZUQ2cb 1E9VSwSMX6Gn4INQmjANzTnIrLTli07sdk93zudiL4UogOL2r/rgJNxVtZF9Q1b3aOFt 3N5csaNWBvye6oEEnrhC2qqB6PaqrGdEE0o2tIx5ctpTDXUU8mYiQVw/AWg9qBHpYYbP PIBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JIOKqtY0; 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 o184-v6si188554qkd.224.2018.06.26.21.43.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 26 Jun 2018 21:43:50 -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=JIOKqtY0; 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]:56539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY2J4-0003sc-0p for patch@linaro.org; Wed, 27 Jun 2018 00:43:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fY29L-00048p-7I for qemu-devel@nongnu.org; Wed, 27 Jun 2018 00:33:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fY29I-0000Gm-3O for qemu-devel@nongnu.org; Wed, 27 Jun 2018 00:33:47 -0400 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]:32906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fY29H-0000FA-Qg for qemu-devel@nongnu.org; Wed, 27 Jun 2018 00:33:43 -0400 Received: by mail-pg0-x236.google.com with SMTP id e11-v6so369956pgq.0 for ; Tue, 26 Jun 2018 21:33:43 -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=iG8HT096URRb4CWAiRTwQ1cVUSLxVdPPA37onBhzXoI=; b=JIOKqtY0fKjngKNtOnlNhv3HvytEvRnFMUiFqNTwwkTmTNbQjz6LQEopDhUjljOdqQ vTlJTwrQVwyFMNdyd0eRza2CYn2mi/5Aut8UMz/tkd4Wm0dAhiMxkr5CNeU0KUGDi7wR qw/bsn3EIjk7zCXyZuTO84Xj0VsrUIESOY1/g= 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=iG8HT096URRb4CWAiRTwQ1cVUSLxVdPPA37onBhzXoI=; b=sRQc1uKaZs2Ax7+Q1DTanFNhznrWaLyRMx4zO2l3bqUcbbU+96SxndZfIiCDd63C1e By8VjvptEBit1UkLmo0C3K2888GDwqLuJGSRFt70+CBJP4Hn3sW8KZm0nKTClUZi5yH6 bhRWp50CWbrwTQR0gV/27aWetl0yVsxcrbzuRrMQv7/j7C6QKV0SUfCgcZfZ7OJ2qa9t XHi2yF/fdn7mS5KZmEXvQm3dAsmMlwCQfEjpxH/QW6hmvhKwuSJqcOoTcVybChdyxbiG VhS2HgjsV158pLlE5+kukCUvy0Bt9d7AoYkp9k/2ct34194vDlINFdKCc3PCz8aGyeod rfow== X-Gm-Message-State: APt69E2GRTaoE9In5YpCP7w3t9PqQOecNRJU7ZtEFe0RV6JrH6BPDU1C pIKgUxWp1O0qUlPDvdlFZ6wNhTKy2WY= X-Received: by 2002:a62:f705:: with SMTP id h5-v6mr4290259pfi.169.1530074022520; Tue, 26 Jun 2018 21:33:42 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id p20-v6sm4577638pff.90.2018.06.26.21.33.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 21:33:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 21:33:01 -0700 Message-Id: <20180627043328.11531-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180627043328.11531-1-richard.henderson@linaro.org> References: <20180627043328.11531-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:c05::236 Subject: [Qemu-devel] [PATCH v6 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, 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 --- 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 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 2f416e5e28..2d08b7dcd3 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 e8531e28cd..675b81aaa0 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)