From patchwork Thu Feb 8 17:31:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 127721 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1757904ljc; Thu, 8 Feb 2018 10:37:55 -0800 (PST) X-Google-Smtp-Source: AH8x226treV5hpgFl7fGImV0Qj3EWBQcfHcZFH5UzZwGh6oTdxhSwtAJq6dXpDVho8L6q3V18vBx X-Received: by 10.13.211.130 with SMTP id v124mr139810ywd.476.1518115075228; Thu, 08 Feb 2018 10:37:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518115075; cv=none; d=google.com; s=arc-20160816; b=l3sBMhWrhIqEzAgp9SP7iirudgTj8OnQNadUfHTB84+WjEGX0B8PhuVSvpDuTLQHUJ ENJ1FySrRexhCwDYhq6p8FX28U6qiT6BDIWDC9r7o+jophjLI6oDSPK2XOC2abL4wxtY rp9OSJsQoo3WbPfNKsEgoRI3EEo0Fd02JCY8kWAEekxQPjnbcswbHFfHfJJvSXnkdpCO 4jhvMfw+E+xayoA7VyHbZYHrZwSzyJJf4EGdVNcpzqFz+JKBzT7XfawgnHbfetlt+BLg nBx1OQvVbtxhNH2rTTcpqQl/RY1TYKEYKlKmNq3fK6pM3m8aYEYcjnAnCxlBG1eTY1eN gz3g== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+gbSDJCRdq+Zc9wfQZR5pTpDA9vK2kya6rCVU185sfM=; b=KZm2fPGZX4J3OKKWpNHDucDu1VRLyut7xlzbiwiRVnRPI8fUZgXwEURZFBUaj7WD69 YT/6s07GIRAbd9YfL6/mLwxR50RJcHDPmwHXPk2oLjDFr4roVk85jTinlEE/TbSRKa3i njAimqKg3CA8mUGUcIP3EgjsDXMqS1j4iF6S1A0PuFVsP5v8hX2veqneblq60W5Ff4ap z0xu1J+WquZWck3aDDJFnPWU21Neg5u+q9GS1EBqLJhw3O9Qa4l5F1q2GwiE6TzETvKh gD+dWUaKwzPbiMY+97xAub+A/ifOvgCWkhytoas6R5lLlFOhTMUmptDfrjWOrSr2K+mA RnDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CcC03tSR; 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 s3si94790ybj.448.2018.02.08.10.37.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Feb 2018 10:37:55 -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=CcC03tSR; 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]:32996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejr50-0002dy-Bx for patch@linaro.org; Thu, 08 Feb 2018 13:37:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejqBb-00037X-Js for qemu-devel@nongnu.org; Thu, 08 Feb 2018 12:40:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejqBZ-0000Zp-Nj for qemu-devel@nongnu.org; Thu, 08 Feb 2018 12:40:39 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:39417) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejqBZ-0000YP-CB for qemu-devel@nongnu.org; Thu, 08 Feb 2018 12:40:37 -0500 Received: by mail-wr0-x243.google.com with SMTP id f6so5595206wra.6 for ; Thu, 08 Feb 2018 09:40:37 -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=+gbSDJCRdq+Zc9wfQZR5pTpDA9vK2kya6rCVU185sfM=; b=CcC03tSRS+XnnOxXe+uCAlockDbx9cQhupq4OR2pN0DKHQpKFAKFnp197jQn2ZwSJN UCseTwfe2dua0l2ZdY1+S8DARFkHcmP+0ga4a/mi25zK9wzlpv+ns2TGlBYZl5WpZctQ pvjRymci5z1bqopPzYNr+iGyCFn5X8p5VcsHA= 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=+gbSDJCRdq+Zc9wfQZR5pTpDA9vK2kya6rCVU185sfM=; b=soD6yF6IFOUOu252WoBejKoC3lVBiuEG/oJtCc9y2+HeEMm5x3jiZbdrEZPaWat9P1 9dD0MigqjuKsV/5pUB8pkr+19kMowixMJdLQ0lmsHt1cteCe7R+O0n9SuzjsbNwz9y3x 0OShZfd7KsiBchce0mbLLJinYu+lVPI8djBFFM9fSWL/i8KgVOfnjenPqj+//Pc9VezR NGvt580VQJm5Nst9n6LVLQat5+5QngJsaKuuMDR1+pUGfyQzZkyYU8g0ggUt3U6mWl7D Dw17gS4iXOIhFBKWVZ+PKCPgAnurJXlLKrrovFJTyBDdh3vQ8hHv0uvXce9Ff9k2XcMZ pEpg== X-Gm-Message-State: APf1xPA0VBYtsd4XCc08SnG9Bda+qyeiFt/3gdijAdTabMZvsbRZeXuI rXLxKz/7kuOAnxuTSvSb6YlaOg== X-Received: by 10.223.200.74 with SMTP id e10mr1527853wrh.128.1518111636012; Thu, 08 Feb 2018 09:40:36 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d73sm501394wma.16.2018.02.08.09.40.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 09:40:30 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E71983E0D02; Thu, 8 Feb 2018 17:31:58 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Thu, 8 Feb 2018 17:31:41 +0000 Message-Id: <20180208173157.24705-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180208173157.24705-1-alex.bennee@linaro.org> References: <20180208173157.24705-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH v2 16/32] arm/translate-a64: add FP16 x2 ops for simd_indexed 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 , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" A bunch of the vectorised bitwise operations just operate on larger chunks at a time. We can do the same for the new half-precision operations by introducing some TWOHALFOP helpers which work on each half of a pair of half-precision operations at once. Hopefully all this hoop jumping will get simpler once we have generically vectorised helpers here. Signed-off-by: Alex Bennée --- v2 - checkpatch fixes --- target/arm/helper-a64.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- target/arm/helper-a64.h | 10 ++++++++++ target/arm/translate-a64.c | 36 +++++++++++++++++++++++++++++------- 3 files changed, 84 insertions(+), 8 deletions(-) -- 2.15.1 Reviewed-by: Richard Henderson diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 6358b42472..8f0f59ea31 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -634,8 +634,32 @@ ADVSIMD_HALFOP(max) ADVSIMD_HALFOP(minnum) ADVSIMD_HALFOP(maxnum) +#define ADVSIMD_TWOHALFOP(name) \ +uint32_t ADVSIMD_HELPER(name, 2h)(uint32_t two_a, uint32_t two_b, void *fpstp) \ +{ \ + float16 a1, a2, b1, b2; \ + uint32_t r1, r2; \ + float_status *fpst = fpstp; \ + a1 = extract32(two_a, 0, 16); \ + a2 = extract32(two_a, 16, 16); \ + b1 = extract32(two_b, 0, 16); \ + b2 = extract32(two_b, 16, 16); \ + r1 = float16_ ## name(a1, b1, fpst); \ + r2 = float16_ ## name(a2, b2, fpst); \ + return deposit32(r1, 16, 16, r2); \ +} + +ADVSIMD_TWOHALFOP(add) +ADVSIMD_TWOHALFOP(sub) +ADVSIMD_TWOHALFOP(mul) +ADVSIMD_TWOHALFOP(div) +ADVSIMD_TWOHALFOP(min) +ADVSIMD_TWOHALFOP(max) +ADVSIMD_TWOHALFOP(minnum) +ADVSIMD_TWOHALFOP(maxnum) + /* Data processing - scalar floating-point and advanced SIMD */ -float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp) +static float16 float16_mulx(float16 a, float16 b, void *fpstp) { float_status *fpst = fpstp; @@ -651,6 +675,9 @@ float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp) return float16_mul(a, b, fpst); } +ADVSIMD_HALFOP(mulx) +ADVSIMD_TWOHALFOP(mulx) + /* fused multiply-accumulate */ float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) { @@ -658,6 +685,23 @@ float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) return float16_muladd(a, b, c, 0, fpst); } +uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b, + uint32_t two_c, void *fpstp) +{ + float_status *fpst = fpstp; + float16 a1, a2, b1, b2, c1, c2; + uint32_t r1, r2; + a1 = extract32(two_a, 0, 16); + a2 = extract32(two_a, 16, 16); + b1 = extract32(two_b, 0, 16); + b2 = extract32(two_b, 16, 16); + c1 = extract32(two_c, 0, 16); + c2 = extract32(two_c, 16, 16); + r1 = float16_muladd(a1, b1, c1, 0, fpst); + r2 = float16_muladd(a2, b2, c2, 0, fpst); + return deposit32(r1, 16, 16, r2); +} + /* * Floating point comparisons produce an integer result. Softfloat * routines return float_relation types which we convert to the 0/-1 diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index d347f473d4..d2dd46d07b 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -61,6 +61,16 @@ DEF_HELPER_3(advsimd_maxnumh, f16, f16, f16, ptr) DEF_HELPER_3(advsimd_minnumh, f16, f16, f16, ptr) DEF_HELPER_3(advsimd_mulxh, f16, f16, f16, ptr) DEF_HELPER_4(advsimd_muladdh, f16, f16, f16, f16, ptr) +DEF_HELPER_3(advsimd_add2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_sub2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_mul2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_div2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_max2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_min2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_maxnum2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_minnum2h, i32, i32, i32, ptr) +DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr) +DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr) DEF_HELPER_3(advsimd_ceq_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 83a1fa3116..f01bab801c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10966,21 +10966,31 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) } case 0x5: /* FMLS */ case 0x1: /* FMLA */ - read_vec_element_i32(s, tcg_res, rd, pass, is_scalar ? size : MO_32); + read_vec_element_i32(s, tcg_res, rd, pass, + is_scalar ? size : MO_32); switch (size) { case 1: if (opcode == 0x5) { - /* As usual for ARM, separate negation for fused multiply-add */ + /* As usual for ARM, separate negation for fused + * multiply-add. */ tcg_gen_xori_i32(tcg_op, tcg_op, 0x80008000); } - gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx, tcg_res, fpst); + if (is_scalar) { + gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx, + tcg_res, fpst); + } else { + gen_helper_advsimd_muladd2h(tcg_res, tcg_op, tcg_idx, + tcg_res, fpst); + } break; case 2: if (opcode == 0x5) { - /* As usual for ARM, separate negation for fused multiply-add */ + /* As usual for ARM, separate negation for fused + * multiply-add. */ tcg_gen_xori_i32(tcg_op, tcg_op, 0x80000000); } - gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx, tcg_res, fpst); + gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx, + tcg_res, fpst); break; default: g_assert_not_reached(); @@ -10990,9 +11000,21 @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) switch (size) { case 1: if (u) { - gen_helper_advsimd_mulxh(tcg_res, tcg_op, tcg_idx, fpst); + if (is_scalar) { + gen_helper_advsimd_mulxh(tcg_res, tcg_op, + tcg_idx, fpst); + } else { + gen_helper_advsimd_mulx2h(tcg_res, tcg_op, + tcg_idx, fpst); + } } else { - g_assert_not_reached(); + if (is_scalar) { + gen_helper_advsimd_mulh(tcg_res, tcg_op, + tcg_idx, fpst); + } else { + gen_helper_advsimd_mul2h(tcg_res, tcg_op, + tcg_idx, fpst); + } } break; case 2: