From patchwork Tue Feb 27 14:38:33 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: 129805 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1472369lja; Tue, 27 Feb 2018 06:45:24 -0800 (PST) X-Google-Smtp-Source: AG47ELtTUA3D/m80p4+I9s4XKEinkfSn7WG+/P3+LhkOEIWtPUcf/fb+nFM2VtYJLrOlzIPZ7PGn X-Received: by 2002:a25:2e0c:: with SMTP id u12-v6mr1646683ybu.369.1519742724460; Tue, 27 Feb 2018 06:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519742724; cv=none; d=google.com; s=arc-20160816; b=itwOhCS6/GnnQ7BKB6+0urGYG0Auddja3qS20ktozITel731vfPDkgAv0ghOpErteQ xOOtv+mjyj7k3rFDnEWKop0D86LlHBMVPcumZS5rM4mguamyGCOHofscttTL/eeT7ARD AAabn9HwqNp7phsf2charnE0JH5WU9B9AFASHVa3XAmPiH7zalGV1kv3YUEhak9NB4Vs UzgS0VJta1oAKyaPvChsxm71SBTXyf6xlz8VhFErSFj6Ekf22ebHdd9q4LrS4Dvs6FkA c+1sWCONX81ZVwvNyYHCUzr3tC2l7Y7qGKIIYfCkGGzojPZxVZyn+ClCi4Edq2snmhyb l6Ig== 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=0Gxj1BXYbejC+76cCVLk/dtD7VuEACO0eicBwCehGSY=; b=0PwValX2TOzKZz0bz6StUdmZRvty2T/5yeLbxl1bO4hCIDF70surrd8PsOQirfOr0E E6hqHWhTO+awaM7w+wA3YSMbgiRbTRDPCfNXSfP5bA5qKqHOdgWZSjgqo/jHvWsD1+Ix XJIS6BKbQm3X7JAvqQ6Bon+BkGvtlYAhg/B/OTY8ZmluyxnYJ0YS+MPRCnyLCwaTjRXt 2YzC2bAX6F90qF6WbfIwJe3OLvuHz/DBomZlMRECNrpNEwoH6sxNYHmxFGmjj25d0gx2 iqtdDZkLegVyAlqt17pBpOTV0BAv6WEPfOHFSaqLt1tji7kb6RG+UaI8X6BccQYiKPUK zNtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QrRVqNEj; 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 n127si1906544ywd.536.2018.02.27.06.45.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Feb 2018 06:45:24 -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=QrRVqNEj; 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]:37689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgVP-0008Rg-Qr for patch@linaro.org; Tue, 27 Feb 2018 09:45:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqgPT-0003mg-D2 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqgPO-00082L-BC for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:15 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32978) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eqgPO-00081r-1c for qemu-devel@nongnu.org; Tue, 27 Feb 2018 09:39:10 -0500 Received: by mail-wm0-x243.google.com with SMTP id s206so21986441wme.0 for ; Tue, 27 Feb 2018 06:39:09 -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=0Gxj1BXYbejC+76cCVLk/dtD7VuEACO0eicBwCehGSY=; b=QrRVqNEj+tNoL2bxhf7cH/TMJz+bJQr0TcpetplijW5OPg6MnI4Ogtx0SrNm3tWPG3 T7JH7Na4hfl5sH7/K2lSJS4icGT7LShJbfMgFzqBCUZB1mhpPhw1Yd2rU+RbSqbTmwrt yns55oml9fhGNX4jpgyGVIWiSJ79AXWGHRXkQ= 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=0Gxj1BXYbejC+76cCVLk/dtD7VuEACO0eicBwCehGSY=; b=OIJhXN9BFvLQQrzBExDXQRR2tt0XbkeqEZRDDQi4SdEdBLHMYl3Qm6LrKUbvIaEObe aEv5jh2R8BowjJir5cj1sderPeChuBYyyQRdClPDWwOUeCufQxrgdS+mKFLgp67FelOh EykIo5WqlXh1iIXhlXZLHSzKJIszWGluPfo7rXSLVx8UPk9Ctg42pWyrwCcZ9XmWtS58 bN530gUILou5VaRDU7jMn7D+uAourP0J5w96QOnNJ31hWNoJvRyCG56HPDQytj8fkCFe fmBONfr3wCvuHzWW+fxoJ/N9ckqckkJetrXnn+eSsYD4oJ4ApKKK+pFI6RuzATFbgPqD VwNw== X-Gm-Message-State: APf1xPBoFRfH9q6sYBrHwbwCpwhGZrbDQJip3gGlkJy9NrDHX/2EIRAi TvZ4gaGz3hhDSgJYWYXvHQxzJw== X-Received: by 10.28.138.143 with SMTP id m137mr4901927wmd.85.1519742348904; Tue, 27 Feb 2018 06:39:08 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m7sm15900547wrm.35.2018.02.27.06.38.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 06:38:59 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id CA9BA3E0AA3; Tue, 27 Feb 2018 14:38:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Tue, 27 Feb 2018 14:38:33 +0000 Message-Id: <20180227143852.11175-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180227143852.11175-1-alex.bennee@linaro.org> References: <20180227143852.11175-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::243 Subject: [Qemu-devel] [PATCH v4 12/31] arm/translate-a64: add FP16 FR[ECP/SQRT]S to simd_three_reg_same_fp16 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: =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, qemu-devel@nongnu.org, Aurelien Jarno , Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As some of the constants here will also be needed elsewhere (specifically for the upcoming SVE support) we move them out to softfloat.h. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - move constants used for estimate to softfloat.h --- include/fpu/softfloat.h | 16 ++++++++++++---- target/arm/helper-a64.c | 34 ++++++++++++++++++++++++++++++++++ target/arm/helper-a64.h | 2 ++ target/arm/translate-a64.c | 6 ++++++ 4 files changed, 54 insertions(+), 4 deletions(-) -- 2.15.1 diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 9b7b5e34e2..27876e711c 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -306,8 +306,11 @@ static inline float16 float16_set_sign(float16 a, int sign) } #define float16_zero make_float16(0) -#define float16_one make_float16(0x3c00) #define float16_half make_float16(0x3800) +#define float16_one make_float16(0x3c00) +#define float16_one_point_five make_float16(0x3e00) +#define float16_two make_float16(0x4000) +#define float16_three make_float16(0x4200) #define float16_infinity make_float16(0x7c00) /*---------------------------------------------------------------------------- @@ -415,11 +418,13 @@ static inline float32 float32_set_sign(float32 a, int sign) } #define float32_zero make_float32(0) -#define float32_one make_float32(0x3f800000) #define float32_half make_float32(0x3f000000) +#define float32_one make_float32(0x3f800000) +#define float32_one_point_five make_float32(0x3fc00000) +#define float32_two make_float32(0x40000000) +#define float32_three make_float32(0x40400000) #define float32_infinity make_float32(0x7f800000) - /*---------------------------------------------------------------------------- | The pattern for a default generated single-precision NaN. *----------------------------------------------------------------------------*/ @@ -526,9 +531,12 @@ static inline float64 float64_set_sign(float64 a, int sign) } #define float64_zero make_float64(0) +#define float64_half make_float64(0x3fe0000000000000LL) #define float64_one make_float64(0x3ff0000000000000LL) +#define float64_one_point_five make_float64(0x3FF8000000000000ULL) +#define float64_two make_float64(0x4000000000000000ULL) +#define float64_three make_float64(0x4008000000000000ULL) #define float64_ln2 make_float64(0x3fe62e42fefa39efLL) -#define float64_half make_float64(0x3fe0000000000000LL) #define float64_infinity make_float64(0x7ff0000000000000LL) /*---------------------------------------------------------------------------- diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 1ef13abd76..8fdbe034f3 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -192,6 +192,10 @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) * versions, these do a fully fused multiply-add or * multiply-add-and-halve. */ +#define float16_two make_float16(0x4000) +#define float16_three make_float16(0x4200) +#define float16_one_point_five make_float16(0x3e00) + #define float32_two make_float32(0x40000000) #define float32_three make_float32(0x40400000) #define float32_one_point_five make_float32(0x3fc00000) @@ -200,6 +204,21 @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) #define float64_three make_float64(0x4008000000000000ULL) #define float64_one_point_five make_float64(0x3FF8000000000000ULL) +float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + + a = float16_squash_input_denormal(a, fpst); + b = float16_squash_input_denormal(b, fpst); + + a = float16_chs(a); + if ((float16_is_infinity(a) && float16_is_zero(b)) || + (float16_is_infinity(b) && float16_is_zero(a))) { + return float16_two; + } + return float16_muladd(a, b, float16_two, 0, fpst); +} + float32 HELPER(recpsf_f32)(float32 a, float32 b, void *fpstp) { float_status *fpst = fpstp; @@ -230,6 +249,21 @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp) return float64_muladd(a, b, float64_two, 0, fpst); } +float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp) +{ + float_status *fpst = fpstp; + + a = float16_squash_input_denormal(a, fpst); + b = float16_squash_input_denormal(b, fpst); + + a = float16_chs(a); + if ((float16_is_infinity(a) && float16_is_zero(b)) || + (float16_is_infinity(b) && float16_is_zero(a))) { + return float16_one_point_five; + } + return float16_muladd(a, b, float16_three, float_muladd_halve_result, fpst); +} + float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, void *fpstp) { float_status *fpst = fpstp; diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 9c1a95594c..79012eee9d 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -29,8 +29,10 @@ DEF_HELPER_FLAGS_3(vfp_mulxd, TCG_CALL_NO_RWG, f64, f64, f64, ptr) DEF_HELPER_FLAGS_3(neon_ceq_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr) DEF_HELPER_FLAGS_3(neon_cge_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr) DEF_HELPER_FLAGS_3(neon_cgt_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr) +DEF_HELPER_FLAGS_3(recpsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(recpsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr) DEF_HELPER_FLAGS_3(recpsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr) +DEF_HELPER_FLAGS_3(rsqrtsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(rsqrtsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr) DEF_HELPER_FLAGS_3(rsqrtsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr) DEF_HELPER_FLAGS_1(neon_addlp_s8, TCG_CALL_NO_RWG_SE, i64, i64) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 0e2d298687..217e73ef58 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10303,6 +10303,9 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0x6: /* FMAX */ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0x7: /* FRECPS */ + gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x8: /* FMINNM */ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); break; @@ -10319,6 +10322,9 @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) case 0xe: /* FMIN */ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); break; + case 0xf: /* FRSQRTS */ + gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst); + break; case 0x13: /* FMUL */ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); break;