From patchwork Fri Oct 13 16:24:29 2017 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: 115800 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp932934qgn; Fri, 13 Oct 2017 09:40:15 -0700 (PDT) X-Received: by 10.55.15.42 with SMTP id z42mr2791440qkg.181.1507912815424; Fri, 13 Oct 2017 09:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507912815; cv=none; d=google.com; s=arc-20160816; b=ouvXObL5QESYkaUZvzuSsAY7WVtfLdncwFBdHBc4kx9BS3vpbSp0xolhSUXzTMf7nh azuCHVQD+GkU/u+DFvOOujKpWhMd8Xwm0/nTp/y5unzo4qqFvOquPPiULKZjiVxB6azP DEWf78ShIfhdcByEJdfCsjQv+AEz6jmIIo4acS06lScvVs8wL5s3zK6y2AKBw2lJb4dY n6SwFn4seWGVsVz+GoE3McUOMaWFdtn9Y5cLv6YWSX81ahcf17c6uEp3YqGrxqi3kE1R HSse/UNf76g8AF3HCeIxh4R+oOHPwceA1E/AIyBmreSXxjNKEXHqEbQbX2m6o3MwOhbE 74YA== 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=WgjrWBed7KjNuOQTB73y78RIIJBwnNFIlmGKPi/MoyY=; b=ZWK1mIdPz3dv2jdIiz41C6xd4nqtX06HZ18qZ9sFcfs9Ry4sLaXXVI42+eyKV+/VF2 uf14j5YTBLMe+p4zWvjkvtGc3LCwCTzLX2ODwxy2UjhwJ1Va7yUtvg1VuuyRbwHugnYy MpMJhuyzwCxfmvDDf6RJJEPSBRWOjIZ4/6LPLnlmAUJ3r4Ut1VfwgFyoU07RIzNi9SXf ryMIW9cNvK9oHUadafIdpQ81cBThXRV6KUJQ4qZZ69xz0slECvHoBF8Z4J0/VhaCffJy ONHMbhALgVdnvLhN7o7WihnN1IABxsSbogZTNLcRb+chdeMySJQ6BqsJDxwN+6zqeF4z yj6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SLf2DR4g; 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 r185si35526qkc.407.2017.10.13.09.40.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Oct 2017 09:40:15 -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=SLf2DR4g; 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]:51107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e330O-00070l-NU for patch@linaro.org; Fri, 13 Oct 2017 12:40:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32se-0000e5-4c for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:32:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e32sc-0002LD-D4 for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:32:11 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:45349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e32sc-0002KX-4L for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:32:10 -0400 Received: by mail-wm0-x235.google.com with SMTP id q124so22584859wmb.0 for ; Fri, 13 Oct 2017 09:32:10 -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 :mime-version:content-transfer-encoding; bh=WgjrWBed7KjNuOQTB73y78RIIJBwnNFIlmGKPi/MoyY=; b=SLf2DR4gU6XUtCfNOPpO3KGkEe8A0sn/R2fQTT3L7RJKALhe95Nil4CmZyL/CVYqCZ kXUIor824Ao18tJWdsdKoJv+Dg+H7RMyQNNbSGdFJ2LRTJNpEzBxllMwTGbn8reb222s MT/iAnCI+TZ7oRa3zaaFFpscG0PuMwH5FoEZg= 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=WgjrWBed7KjNuOQTB73y78RIIJBwnNFIlmGKPi/MoyY=; b=hcs/UPXhHZrbDOILvdV+C84vXPe7U0IQSF4L/3DG1ypr1Umv8wS4RkWehIVLh5lTay rlSyoa4mXLRJJ/Necs0IhqzocUdQLC/KIy3xoWWJyYD3rC85E5WH2Q6ZP6OzhL/51k7H 4reWxTaNk+layhUkwCJMPNiiQiWdlpUmeHum33mKaSn5Ue5rp1MSf/3OBhYmfbg86SwW fXNgvnhsAaiusoqOuKncQ9fJMz1Oa2SKQ0L3um1+bQ+G08jY3nlf/P1h+stZ1OScomlV 4TWtndZs7pXXgal2Z2FXHQMz1iJuc+59QTuQ5jbWkL/iXhQ0tL2bM0J86vuTBqD7z9hO yLyQ== X-Gm-Message-State: AMCzsaXddcjA3MtYmHX+nUeBO4dOxuXY+YUIOsqRgndhbFztEzdJW7bl 2HAglkqM4+CS4416QHbpFYBcZQ== X-Google-Smtp-Source: ABhQp+TA1WlA16hRQPAZpV5K39+6jg9VN4c10bI4WMChwur/35YWazYNcXw5nMIq5kenBGm8c0D7Og== X-Received: by 10.28.92.133 with SMTP id q127mr1758300wmb.26.1507912328937; Fri, 13 Oct 2017 09:32:08 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c45sm1611907wrg.97.2017.10.13.09.32.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 09:32:03 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id EB3443E0FB9; Fri, 13 Oct 2017 17:24:39 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org Date: Fri, 13 Oct 2017 17:24:29 +0100 Message-Id: <20171013162438.32458-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171013162438.32458-1-alex.bennee@linaro.org> References: <20171013162438.32458-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:c09::235 Subject: [Qemu-devel] [RFC PATCH 21/30] target/arm/translate-a64: add FP16 2-reg misc compare (zero) 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, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I re-use the existing handle_2misc_fcmp_zero handler and tweak it slightly to deal with the half-precision case. Signed-off-by: Alex Bennée --- target/arm/helper-a64.c | 39 +++++++++++++++++++++++++++++++++++++++ target/arm/helper-a64.h | 6 ++++++ target/arm/translate-a64.c | 25 ++++++++++++++++++------- 3 files changed, 63 insertions(+), 7 deletions(-) -- 2.14.1 diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index dd26675d5c..b62d77aec4 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -577,3 +577,42 @@ float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp) } return float16_mul(a, b, fpst); } + + +/* + * Floating point comparisons produce an integer result. + * Softfloat routines return 0/1, which we convert to the 0/-1 Neon requires. + */ +uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + return -float16_eq_quiet(a, b, fpst); +} + +uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + return -float16_le(b, a, fpst); +} + +uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + return -float16_lt(b, a, fpst); +} + +uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + float16 f0 = float16_abs(a); + float16 f1 = float16_abs(b); + return -float16_le(f1, f0, fpst); +} + +/* uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) */ +/* { */ +/* float_status *fpst = fpstp; */ +/* float16 f0 = float16_abs(a); */ +/* float16 f1 = float16_abs(b); */ +/* return -float16_lt(f1, f0, fpst); */ +/* } */ diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 0f97eb607f..952869f43e 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -53,3 +53,9 @@ DEF_HELPER_3(advsimd_minh, f16, f16, f16, ptr) 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_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) +DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr) +DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 7792cea9f5..623b0b3fab 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7785,6 +7785,7 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, TCGv_i32 tcg_res = tcg_temp_new_i32(); NeonGenTwoSingleOPFn *genfn; bool swap = false; + bool hp = (size == 1 ? true : false); int pass, maxpasses; switch (opcode) { @@ -7792,7 +7793,7 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, swap = true; /* fall through */ case 0x2c: /* FCMGT (zero) */ - genfn = gen_helper_neon_cgt_f32; + genfn = hp ? gen_helper_advsimd_cgt_f16 : gen_helper_neon_cgt_f32; break; case 0x2d: /* FCMEQ (zero) */ genfn = gen_helper_neon_ceq_f32; @@ -7814,7 +7815,7 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, } for (pass = 0; pass < maxpasses; pass++) { - read_vec_element_i32(s, tcg_op, rn, pass, MO_32); + read_vec_element_i32(s, tcg_op, rn, pass, hp ? MO_16 : MO_32); if (swap) { genfn(tcg_res, tcg_zero, tcg_op, fpst); } else { @@ -7823,7 +7824,7 @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, if (is_scalar) { write_fp_sreg(s, rd, tcg_res); } else { - write_vec_element_i32(s, tcg_res, rd, pass, MO_32); + write_vec_element_i32(s, tcg_res, rd, pass, hp ? MO_16 : MO_32); } } tcg_temp_free_i32(tcg_res); @@ -9809,6 +9810,9 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0x2: /* FADD */ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x6: /* FMAX */ + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x23: /* FMUL */ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); break; @@ -10580,21 +10584,28 @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) { int fpop, opcode, a; + int rn, rd; if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { unallocated_encoding(s); return; } - if (!fp_access_check(s)) { - return; - } - opcode = extract32(insn, 12, 4); a = extract32(insn, 23, 1); fpop = deposit32(opcode, 5, 1, a); + rn = extract32(insn, 5, 5); + rd = extract32(insn, 0, 5); + switch (fpop) { + case 0x2c: /* FCMGT (zero) */ + case 0x2d: /* FCMEQ (zero) */ + case 0x2e: /* FCMLT (zero) */ + case 0x6c: /* FCMGE (zero) */ + case 0x6d: /* FCMLE (zero) */ + handle_2misc_fcmp_zero(s, fpop, true, 0, false, 1, rn, rd); + break; default: fprintf(stderr,"%s: insn %#04x fpop %#2x\n", __func__, insn, fpop); g_assert_not_reached();