From patchwork Sat Feb 17 18:23:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 128734 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1854139ljc; Sat, 17 Feb 2018 11:24:54 -0800 (PST) X-Google-Smtp-Source: AH8x226+yrjldBO9jvnMcSH6LNOKsKRMbjVdoxnmb4AmnBumSabfn42UBflSixGKuWNTuYwF82WS X-Received: by 10.37.17.193 with SMTP id 184mr1415453ybr.392.1518895494620; Sat, 17 Feb 2018 11:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518895494; cv=none; d=google.com; s=arc-20160816; b=i08SzgPDTUnqwlbm2poLLENceBky2t2SOZFg1awZhVDCGRWqmxgfCkF6J6GI/gAYKR tptCnUQuHwdEXte0G8cO2P6Dw3C1qeQPZ3CwhINU87vA1W5ZroVVJGFI5izKiDWEtqW6 jR/WlYh2xH5GIebb25mizf8C3LgRXKOTEca57RwvnB85yGS60WL+xD8UtRxN0RhmNtAi sxmf5QqnHHJRsiZ0RTSFszem7AS7VlQnNQoQjX5gKjL7a47h+SQFKZ29DV9itpmYkkKg bFpjrli17TpkbMKQ3BF3RBthDHjc4thEOIriAjEAqNFDuJwVjEyP/epzdKIc1KSXpA9c 7sTA== 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=cokBBhuDkWzo28jRgpOw6j/fAbncWNu8+0qc6t2uB2A=; b=kXI68n/VNodnmMZHRFE53sy3c+YsamuXJt+cTz22V2tFjm22Erzrwbj2Evmskyjl0Z zkJEbJD9JOyNWuw+GjZLCuwa64lsW+OjKaeHxsaEMfIn9fxD542pYVv14CY9vP5kzunH uNj3PXNtlycYA6fkJ243mqPyo9kgea2yDq8npOaEf7kW/wTrS9pPPsIPBEIfdfgjXu22 rHaZcF6PH6Dfpp3me4MR6cbEC/LfTpvS4XbhfspAuXi4KhnKSlZAHY2iBvxHyUn3CNkQ gMfl/Q38nZsIVgiER63KEtFwzmfCdIzucjnVKjQD+LFnjXsaMYZRwidCEk596XYfSKpW 2YTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VAo/oF8A; 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 b203si1326714ywc.129.2018.02.17.11.24.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 17 Feb 2018 11:24:54 -0800 (PST) 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=VAo/oF8A; 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]:49522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en86P-0001us-Rj for patch@linaro.org; Sat, 17 Feb 2018 14:24:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en7AG-0001Ts-Us for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:24:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1en7AF-00028D-Nx for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:24:48 -0500 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:43140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1en7AF-00027k-8N for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:24:47 -0500 Received: by mail-pl0-x244.google.com with SMTP id f4so3436597plr.10 for ; Sat, 17 Feb 2018 10:24:47 -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; bh=cokBBhuDkWzo28jRgpOw6j/fAbncWNu8+0qc6t2uB2A=; b=VAo/oF8A+CY8ToSIg/4fbQP52ZtyxwcUn0hg4PSmo+ru7LWv7WHA/UuerjwCRlOzz4 NnjH5dK+8OVJLUlan+plCftRZjgD1QsyQN+DxXWcSbAqdrGNnroV4dRLCwNc4Mi5xvoT EEP9qMp2RVsDTH1sKJYoz3Fa2ib42s6P3/pzU= 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=cokBBhuDkWzo28jRgpOw6j/fAbncWNu8+0qc6t2uB2A=; b=qKoeP2YVJIkdXrJ00DRMSmtjMTytztNtEHC12ZrJTlXMNU16OgzsBJwh08uTJVa0fn u/2pOUA7RRBSNUXuG64oi/5+AaSWMq/qkxzAxyTUdWCtMdVpPCL42Av5I+dr4miWQL9a GZ6lCedj2MfnG+qr+ADVFeeIONu1ernqu1cwjIIakCZsqi8UcbccY3cqha5Fs1bt5C/t vGwczhP/Vj77AAGyQnDju09GWy54Vsf9nXR6ExY/6F0889UG63wsv7/l0ZKLr/3Z7wXQ 8PU2XDBkmfvt1l20oRgrHMCaPjGFWrxOQ3CpRJge82SYwo6A/8M0vfA5XmmBs+7F/o+5 h8IQ== X-Gm-Message-State: APf1xPAtstjNX1KbKB5HtLjHZJXcwWmQ1uME2Lizt6deFs4a5LQF4fAT xPSzVXnPZVQ4elcNTe5hzlshM1cEWyY= X-Received: by 2002:a17:902:2bc5:: with SMTP id l63-v6mr9565360plb.108.1518891886027; Sat, 17 Feb 2018 10:24:46 -0800 (PST) Received: from cloudburst.twiddle.net ([50.0.192.64]) by smtp.gmail.com with ESMTPSA id h15sm13466712pfi.56.2018.02.17.10.24.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Feb 2018 10:24:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 17 Feb 2018 10:23:06 -0800 Message-Id: <20180217182323.25885-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180217182323.25885-1-richard.henderson@linaro.org> References: <20180217182323.25885-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:c01::244 Subject: [Qemu-devel] [PATCH v2 50/67] 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: qemu-arm@nongnu.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 | 42 ++++++++++++++++++++++++++++++++++ target/arm/sve.decode | 5 +++++ 4 files changed, 110 insertions(+) -- 2.14.3 Reviewed-by: Peter Maydell diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index a95f077c7f..c4502256d5 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 6622275b44..0e2b3091b0 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -2789,6 +2789,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 3124368fb5..32f0340738 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -3120,6 +3120,48 @@ DO_ZZI(UMIN, umin) #undef DO_ZZI +/* + *** SVE Floating Point Accumulating Reduction Group + */ + +static void 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) { + unallocated_encoding(s); + return; + } + + 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); +} + /* *** SVE Floating Point Arithmetic - Unpredicated Group */ diff --git a/target/arm/sve.decode b/target/arm/sve.decode index 817833f96e..95a290aed0 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -684,6 +684,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)