From patchwork Thu Feb 8 17:31:44 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: 127711 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1734007ljc; Thu, 8 Feb 2018 10:08:19 -0800 (PST) X-Google-Smtp-Source: AH8x2262J4oHVAoJfH5dvNsmHfjOM+p26fJAJRbnwmLjnYVIMhElzMdURdYSapy62PLUrMghTgv/ X-Received: by 10.37.73.194 with SMTP id w185mr27804yba.427.1518113299697; Thu, 08 Feb 2018 10:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518113299; cv=none; d=google.com; s=arc-20160816; b=KevBJYpplVVjYbGyo5zTS9kogVpFLfrsyq8uNuGDRB1LkTQ0LXOSCdIXdEqn2k3kzd HYkP86irIRdkE+//Lx498dr+Y9aHDhidumGRnQ5s8xm1YQKRHJduaBmoZOUJbYwu57lY rZ9lKptCADBPySc+w7DJZwiz8BVKm1xwzhENpv6L0AcAR5tCoi1FaBeSyUTPIp/K/xWC jQ8GqjVFqbVsIW5XXPe8SdA/zTT+FOPecfjazHdqrOWtwgkWMqbQParM8o7Z/f96KzVN UP2voRe9egDKD5+StY/8fMt+DbjmYaByHD77NXz1qVs+QfXFWS8oGFt4xsaWwPC0k0iA jXrQ== 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=9e/cIvJOEXVul/QTqPr7Bzfwdn7CVfZFq2X2Iak7uMg=; b=Ibxq0Y/9MCOucWd6LKseR+Xm/rD+WGcnaQBoyn2YVw4dtCcWLIYXaREk9myLApIUqp 76mS6dpyTR5bgdysMnDVl4Rtf/gX1u2sH4z7aFz1SihZzm3tV3FdVfo9eLjphFe+tYrA Xry6sLubF28umJKOGouNHk3+fDfmFgWLQzv7Amq/37TUVHOVCIqBzN+J4GRsBURYggYc MiTxAosG+YG1feipv24t6NMC8wuZzwa994GibzXHrnnk6dA3zbTkC91/8UY2gWZPM2BQ TCBHCtTKDijmQid1IVL69K5Qj8DZRkqWR5vaxqrOaDnig+YkEslxhTNWqkeL8EyfPZdI nzWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DUgQFcoC; 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 ([2001:4830:134:3::11]) by mx.google.com with ESMTPS id e9si85417ywb.550.2018.02.08.10.08.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 08 Feb 2018 10:08:19 -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=DUgQFcoC; 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]:58317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejqcM-00025K-U4 for patch@linaro.org; Thu, 08 Feb 2018 13:08:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejq3a-0003Wq-Lm for qemu-devel@nongnu.org; Thu, 08 Feb 2018 12:32:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejq3X-00070f-57 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 12:32:22 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:52159) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ejq3W-0006z9-R4 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 12:32:19 -0500 Received: by mail-wm0-x241.google.com with SMTP id r71so10969722wmd.1 for ; Thu, 08 Feb 2018 09:32:18 -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=9e/cIvJOEXVul/QTqPr7Bzfwdn7CVfZFq2X2Iak7uMg=; b=DUgQFcoCuDA7qlprprgKm5VUpaDXpRHuX2WDILZSmraVRKCX+5PQ+z9ZQhOVxpmDJp TzXb/2uj+yfVLLRbBFYbVpRzh2evkIpBrBSs4gon9OaVKeONlfuFqRLTB+HltdBMi45t D73D2Fs2hRInSYrhEL/ne01w6gBXH9tAfGfEA= 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=9e/cIvJOEXVul/QTqPr7Bzfwdn7CVfZFq2X2Iak7uMg=; b=nWagxLusmFEyVjJ8QRqWl2X4JvAjWVFyqIJnwIkvEw3X0dSTcumUd94aODBeJJY3b2 N7foaWXv+Vd/AmpMgkSnzIwIfOrFpzqBffS+5fAEWRyRPpYrbD85BFUzwaHBAPdaNplG xTzUnIfwdCPkjr1lQlIxfShzqNkVWm7BTSkvJN1VUuvZNwKNI33LJmHrFE5Ql7p6nF1u NsFe56W8ZQlfNQHcJcYsmMxmjfqkq1qSFYgKGSSxgMbU4vwlUFSOWYBw/5X3IilGHWu1 YxIqyqA7fWBPKf9TneDFz0UQwRGdAYqzwikVDWL8DkNunrYX6gzFzkdg0uitG3p0BnlA pY5w== X-Gm-Message-State: APf1xPC/QCvwtJTk36V7grj/K1kXnH+WmU4E+++yiMHKJYoyUqILyrrY W3TtzIUf8z+0A9wx9PMUpvg2XyacmrA= X-Received: by 10.28.128.82 with SMTP id b79mr12682wmd.113.1518111137702; Thu, 08 Feb 2018 09:32:17 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g127sm441215wmf.5.2018.02.08.09.32.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 09:32:11 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2B5553E0D84; Thu, 8 Feb 2018 17:31:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-arm@nongnu.org Date: Thu, 8 Feb 2018 17:31:44 +0000 Message-Id: <20180208173157.24705-20-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:c09::241 Subject: [Qemu-devel] [PATCH v2 19/32] arm/translate-a64: add FCVTxx to simd_two_reg_misc_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: 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" This covers all the floating point convert operations. Signed-off-by: Alex Bennée --- target/arm/helper-a64.c | 32 +++++++++++++++++ target/arm/helper-a64.h | 2 ++ target/arm/translate-a64.c | 85 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 118 insertions(+), 1 deletion(-) -- 2.15.1 Reviewed-by: Richard Henderson diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 919b073635..76f3289e37 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -772,3 +772,35 @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) return ret; } + +/* + * Half-precision floating point conversion functions + * + * There are a multitude of conversion functions with various + * different rounding modes. This is dealt with by the calling code + * setting the mode appropriately before calling the helper. + */ + +uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) +{ + float_status *fpst = fpstp; + + /* Invalid if we are passed a NaN */ + if (float16_is_any_nan(a)) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int16(a, fpst); +} + +uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) +{ + float_status *fpst = fpstp; + + /* Invalid if we are passed a NaN */ + if (float16_is_any_nan(a)) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint16(a, fpst); +} diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index b583bc0dd8..453753f4e7 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -78,3 +78,5 @@ DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr) DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr) DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr) DEF_HELPER_2(advsimd_rinth, f16, f16, ptr) +DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr) +DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index a0506f094f..0049111e6d 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10797,6 +10797,46 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) only_in_vector = true; /* current rounding mode */ break; + case 0x1a: /* FCVTNS */ + need_rmode = true; + rmode = FPROUNDING_TIEEVEN; + break; + case 0x1b: /* FCVTMS */ + need_rmode = true; + rmode = FPROUNDING_NEGINF; + break; + case 0x1c: /* FCVTAS */ + need_rmode = true; + rmode = FPROUNDING_TIEAWAY; + break; + case 0x3a: /* FCVTPS */ + need_rmode = true; + rmode = FPROUNDING_POSINF; + break; + case 0x3b: /* FCVTZS */ + need_rmode = true; + rmode = FPROUNDING_ZERO; + break; + case 0x5a: /* FCVTNU */ + need_rmode = true; + rmode = FPROUNDING_TIEEVEN; + break; + case 0x5b: /* FCVTMU */ + need_rmode = true; + rmode = FPROUNDING_NEGINF; + break; + case 0x5c: /* FCVTAU */ + need_rmode = true; + rmode = FPROUNDING_TIEAWAY; + break; + case 0x7a: /* FCVTPU */ + need_rmode = true; + rmode = FPROUNDING_POSINF; + break; + case 0x7b: /* FCVTZU */ + need_rmode = true; + rmode = FPROUNDING_ZERO; + break; default: fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop); g_assert_not_reached(); @@ -10830,7 +10870,36 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) } if (is_scalar) { - /* no operations yet */ + TCGv_i32 tcg_op = tcg_temp_new_i32(); + TCGv_i32 tcg_res = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op, rn, 0, MO_16); + + switch (fpop) { + case 0x1a: /* FCVTNS */ + case 0x1b: /* FCVTMS */ + case 0x1c: /* FCVTAS */ + case 0x3a: /* FCVTPS */ + case 0x3b: /* FCVTZS */ + gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus); + break; + case 0x5a: /* FCVTNU */ + case 0x5b: /* FCVTMU */ + case 0x5c: /* FCVTAU */ + case 0x7a: /* FCVTPU */ + case 0x7b: /* FCVTZU */ + gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus); + break; + default: + g_assert_not_reached(); + } + + /* limit any sign extension going on */ + tcg_gen_andi_i32(tcg_res, tcg_res, 0xffff); + write_fp_sreg(s, rd, tcg_res); + + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_op); } else { for (pass = 0; pass < (is_q ? 8 : 4); pass++) { TCGv_i32 tcg_op = tcg_temp_new_i32(); @@ -10839,6 +10908,20 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) read_vec_element_i32(s, tcg_op, rn, pass, MO_16); switch (fpop) { + case 0x1a: /* FCVTNS */ + case 0x1b: /* FCVTMS */ + case 0x1c: /* FCVTAS */ + case 0x3a: /* FCVTPS */ + case 0x3b: /* FCVTZS */ + gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus); + break; + case 0x5a: /* FCVTNU */ + case 0x5b: /* FCVTMU */ + case 0x5c: /* FCVTAU */ + case 0x7a: /* FCVTPU */ + case 0x7b: /* FCVTZU */ + gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus); + break; case 0x18: /* FRINTN */ case 0x19: /* FRINTM */ case 0x38: /* FRINTP */