From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597609; cv=none; d=zohomail.com; s=zohoarc; b=VxhGsxONS2lJcmmAzTp8bXf7HvUfJrNhil6kCRAdakhhK6+2WXJC9nuF4D5zUpzcDolg/ra/kcNFT+XRz9mjRGl8QuQ/GzwYoOyXDton8ukP2g9U/UX27SyjBk4vHD9e8KcIZaVtyhhs2AewiWclQwiEad1olpU0RrI7U209A8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597609; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GncszkEgwglTonYocdMsdu6HF/IGFXfTlLQ3szXvQlg=; b=ky9xLvj2UNFUHFguicCbLSwctbaglcroIC7CYGdrwN00Mf2t162jsmvlOx7tbEC21uZmqfhz08Bz0MDwTiTsucz1JWr6k0BFG5dcxQXZbuukt9Vx+7Yy1yYAHjBYbP9e1iTREvz555h0ftjiS/T1GKzhcwzVqu/8tOgQU9TDgLA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594597609040512.2417161876906; Sun, 12 Jul 2020 16:46:49 -0700 (PDT) Received: from localhost ([::1]:52782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1julgF-0000FO-DX for importer@patchew.org; Sun, 12 Jul 2020 19:46:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julfD-00072m-GR for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:44 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:39413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007FG-Td for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:43 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:27 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.08604655|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.191123-0.000352562-0.808525; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03306; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 1/8] fpu/softfloat: fix up float16 nan recognition Date: Mon, 13 Jul 2020 07:45:14 +0800 Message-Id: <20200712234521.3972-2-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson --- fpu/softfloat-specialize.inc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpu/softfloat-specialize.inc.c b/fpu/softfloat-specialize.inc.c index 44f5b661f8..034d18199c 100644 --- a/fpu/softfloat-specialize.inc.c +++ b/fpu/softfloat-specialize.inc.c @@ -254,7 +254,7 @@ bool float16_is_quiet_nan(float16 a_, float_status *sta= tus) if (snan_bit_is_one(status)) { return (((a >> 9) & 0x3F) =3D=3D 0x3E) && (a & 0x1FF); } else { - return ((a & ~0x8000) >=3D 0x7C80); + return ((a >> 9) & 0x3F) =3D=3D 0x3F; } #endif } @@ -271,7 +271,7 @@ bool float16_is_signaling_nan(float16 a_, float_status = *status) #else uint16_t a =3D float16_val(a_); if (snan_bit_is_one(status)) { - return ((a & ~0x8000) >=3D 0x7C80); + return ((a >> 9) & 0x3F) =3D=3D 0x3F; } else { return (((a >> 9) & 0x3F) =3D=3D 0x3E) && (a & 0x1FF); } --=20 2.23.0 From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597698; cv=none; d=zohomail.com; s=zohoarc; b=ecRa1g7+8tNTxpvCybQnOcGI9HhqmIoa30FcvNrXZI54xa9kyvprzA71E60V//VZwvmamJmoZdwHshTpXgmlULtWSDrEsFG3KP+L/2X76PGf63Q+V3PxiyV1yAzBpDmDfeJpFndKqRShxcfyDliR85MEajv9BbPHgcKCNIwKRkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597698; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UQFGVRFtWh/xBWtJzhmd+pAZStKYwqWVVL2Xa/AfO4Y=; b=I+mSAHGxzwA0TkNPi0AY1f4vaP+5LGH0PA9YUHgnONp2H2NYDgLgGBmmYj9O/yWdBzpEOyb7eGFJGem06j9+sESYqtvwlJqmr0BV+vbpP2pmy2t4NpemZ9KqrtyO3T3i20DbEoBCEmzK6moYkkmZDjjD2hb/AlUwIu+rE3gsu74= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594597698321850.2559901922675; Sun, 12 Jul 2020 16:48:18 -0700 (PDT) Received: from localhost ([::1]:32942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1julhh-0003bT-3f for importer@patchew.org; Sun, 12 Jul 2020 19:48:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julfC-00072k-VQ for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:44 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:35461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007FH-T4 for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:42 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:27 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.08104733|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_alarm|0.159639-0.000141355-0.840219; FP=0|0|0|0|0|-1|-1|-1; HT=e01l07447; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 2/8] fpu/softfloat: use the similiar logic to recognize sNaN and qNaN Date: Mon, 13 Jul 2020 07:45:15 +0800 Message-Id: <20200712234521.3972-3-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei --- fpu/softfloat-specialize.inc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fpu/softfloat-specialize.inc.c b/fpu/softfloat-specialize.inc.c index 034d18199c..6b778a7830 100644 --- a/fpu/softfloat-specialize.inc.c +++ b/fpu/softfloat-specialize.inc.c @@ -292,7 +292,7 @@ bool float32_is_quiet_nan(float32 a_, float_status *sta= tus) if (snan_bit_is_one(status)) { return (((a >> 22) & 0x1FF) =3D=3D 0x1FE) && (a & 0x003FFFFF); } else { - return ((uint32_t)(a << 1) >=3D 0xFF800000); + return ((a >> 22) & 0x1FF) =3D=3D 0x1FF; } #endif } @@ -309,7 +309,7 @@ bool float32_is_signaling_nan(float32 a_, float_status = *status) #else uint32_t a =3D float32_val(a_); if (snan_bit_is_one(status)) { - return ((uint32_t)(a << 1) >=3D 0xFF800000); + return ((a >> 22) & 0x1FF) =3D=3D 0x1FF; } else { return (((a >> 22) & 0x1FF) =3D=3D 0x1FE) && (a & 0x003FFFFF); } @@ -647,7 +647,7 @@ bool float64_is_quiet_nan(float64 a_, float_status *sta= tus) return (((a >> 51) & 0xFFF) =3D=3D 0xFFE) && (a & 0x0007FFFFFFFFFFFFULL); } else { - return ((a << 1) >=3D 0xFFF0000000000000ULL); + return ((a >> 51) & 0xFFF) =3D=3D 0xFFF; } #endif } @@ -664,7 +664,7 @@ bool float64_is_signaling_nan(float64 a_, float_status = *status) #else uint64_t a =3D float64_val(a_); if (snan_bit_is_one(status)) { - return ((a << 1) >=3D 0xFFF0000000000000ULL); + return ((a >> 51) & 0xFFF) =3D=3D 0xFFF; } else { return (((a >> 51) & 0xFFF) =3D=3D 0xFFE) && (a & UINT64_C(0x0007FFFFFFFFFFFF)); --=20 2.23.0 From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597702; cv=none; d=zohomail.com; s=zohoarc; b=A9XjScMS+jNJfltb5ejBIzEuOKzn1O9RXB4VvSypaHSVcLWMssAHuSTdDbyonJ0Yovm6StJvfCXI1gwOdeWc/AVwYLRjDRIBFtmXxenLZwyeegW5fg2i/8VYGu950rsgNwTYYQ186kfkC8i03z9ofq64/XVuwddm68lh1k4JEYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597702; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tfvAZvsx+Z50ixGyeCL4hYeLRAfDFrLiMQufC0/ItvM=; b=mWKQ1HxUqfgLuqVoT6VrRTqKc+N3pauDAn2ITNiNZfP9eBU/bPFBib6uJnY/Q2+/xTW9KntBlri4QZjSF1Dp3CgQTvAA/g4sfOkZNvF4UIKd7QD2Izx9XqjxzXDqZ9K5NgdQ4txF6qU1pf4LWvm9+Y2IVSQYhfONmT8gEczcmsk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15945977024248.31403318208038; Sun, 12 Jul 2020 16:48:22 -0700 (PDT) Received: from localhost ([::1]:33260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1julhl-0003jF-5e for importer@patchew.org; Sun, 12 Jul 2020 19:48:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julfF-00074T-0E for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:45 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:46503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007FP-TO for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:44 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:28 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.3111103|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.0280463-0.000471656-0.971482; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03293; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 3/8] fpu/softfloat: add FloatFmt for bfloat16 Date: Mon, 13 Jul 2020 07:45:16 +0800 Message-Id: <20200712234521.3972-4-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson --- fpu/softfloat.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 79be4f5840..1ef07d9160 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -554,6 +554,10 @@ static const FloatFmt float16_params_ahp =3D { .arm_althp =3D true }; =20 +static const FloatFmt bfloat16_params =3D { + FLOAT_PARAMS(8, 7) +}; + static const FloatFmt float32_params =3D { FLOAT_PARAMS(8, 23) }; --=20 2.23.0 From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597608; cv=none; d=zohomail.com; s=zohoarc; b=Tc3LfecLPe6ijQg7Z3HtSTP/MyX+bA0kjbvW+TzNiePHbWP01F5gYM/GEvGkMuTGei9yLmiqGQoFJZaJep8r8jMnGsuT8WKBe5ziqapx61pC5snTszRGAZLe+6jZ+nTNglrgjUePlyBoswoHIxb44/eWmAY3+RZ955c5Q25NAVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597608; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PuT8RQesVwgeJ5VtOUvpzwOzoNlTFKIaSZKRQEgK7RI=; b=IeNL9uUmLgwyQ7YPkNFzkxeZJ7dWcKCizyNAWELydSApq7kbbJ5i7Ih6kCRjjRvglbDRmHAz9a0rDmy8hYip5HQJMyDuI9tpBH9Laj4gT1d+H5U2UJ+orSscec/7Y+XLcAjohjRVRlbXjVlDS45EESqd/ca6eiAdtEjx8ePRPQE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159459760854131.91753337821399; Sun, 12 Jul 2020 16:46:48 -0700 (PDT) Received: from localhost ([::1]:52666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1julgE-0000CS-BK for importer@patchew.org; Sun, 12 Jul 2020 19:46:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf9-00071U-L4 for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:39 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:40354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007FR-SE for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:39 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:28 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.1599363|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_regular_dialog|0.0812999-0.000950342-0.91775; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03302; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 4/8] fpu/softfloat: add pack and unpack interfaces for bfloat16 Date: Mon, 13 Jul 2020 07:45:17 +0800 Message-Id: <20200712234521.3972-5-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei --- fpu/softfloat.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 1ef07d9160..54fc889446 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -584,6 +584,11 @@ static inline FloatParts float16_unpack_raw(float16 f) return unpack_raw(float16_params, f); } =20 +static inline FloatParts bfloat16_unpack_raw(bfloat16 f) +{ + return unpack_raw(bfloat16_params, f); +} + static inline FloatParts float32_unpack_raw(float32 f) { return unpack_raw(float32_params, f); @@ -607,6 +612,11 @@ static inline float16 float16_pack_raw(FloatParts p) return make_float16(pack_raw(float16_params, p)); } =20 +static inline bfloat16 bfloat16_pack_raw(FloatParts p) +{ + return make_bfloat16(pack_raw(bfloat16_params, p)); +} + static inline float32 float32_pack_raw(FloatParts p) { return make_float32(pack_raw(float32_params, p)); @@ -824,6 +834,11 @@ static FloatParts float16_unpack_canonical(float16 f, = float_status *s) return float16a_unpack_canonical(f, s, &float16_params); } =20 +static FloatParts bfloat16_unpack_canonical(bfloat16 f, float_status *s) +{ + return sf_canonicalize(bfloat16_unpack_raw(f), &bfloat16_params, s); +} + static float16 float16a_round_pack_canonical(FloatParts p, float_status *s, const FloatFmt *params) { @@ -835,6 +850,11 @@ static float16 float16_round_pack_canonical(FloatParts= p, float_status *s) return float16a_round_pack_canonical(p, s, &float16_params); } =20 +static bfloat16 bfloat16_round_pack_canonical(FloatParts p, float_status *= s) +{ + return float16a_round_pack_canonical(p, s, &bfloat16_params); +} + static FloatParts float32_unpack_canonical(float32 f, float_status *s) { return sf_canonicalize(float32_unpack_raw(f), &float32_params, s); --=20 2.23.0 From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597699; cv=none; d=zohomail.com; s=zohoarc; b=VFstbWb+s03kMPPWeGi8CEs472m/6EMZeNOx3rphT2riFO3LGUMWgftZsmrzAGHj6kd72SSJ+B4azejfHHqk6RXevyGH3tDRQBIYyONUlUkI6VT8PF+Be+IHMDvtd7O/idIBHeYmhccCzjBROOYqAvDeBg8eNbJPnQNMRKem6qI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597699; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ToRcHREn8FNKoHsmFQJyLGrhcTEFAvBbdz2avQfTY/w=; b=S9U8ceozT6KVy6jYXfvm7PYYHyQxOhb0MK3Yk0pQByCNsK+bJI8f9y8YVumWG8d6YW1YRunqO8ROwU02Wk/cAYxd03F+jLsztQe1dQH98amkMZKAdV9eylbEAte+5pwLGjWJRawkVDzZZPOLcP9wVNOY2/tSmHB/oglJh/9nE90= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594597699693385.2470798861805; Sun, 12 Jul 2020 16:48:19 -0700 (PDT) Received: from localhost ([::1]:33050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1julhi-0003e6-FH for importer@patchew.org; Sun, 12 Jul 2020 19:48:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julfB-00071x-HV for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:41 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:60905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007FS-T1 for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:41 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:28 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.2329539|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.0445976-0.00064884-0.954754; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03294; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 5/8] fpu/softfloat: define brain floating-point types Date: Mon, 13 Jul 2020 07:45:18 +0800 Message-Id: <20200712234521.3972-6-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei --- include/fpu/softfloat-types.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 7680193ebc..8f8fdfeecf 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -112,6 +112,14 @@ typedef struct { #define make_float128(high_, low_) ((float128) { .high =3D high_, .low =3D= low_ }) #define make_float128_init(high_, low_) { .high =3D high_, .low =3D low_ } =20 +/* + * Software brain floating-point types + */ +typedef uint16_t bfloat16; +#define bfloat16_val(x) (x) +#define make_bfloat16(x) (x) +#define const_bfloat16(x) (x) + /* * Software IEC/IEEE floating-point underflow tininess-detection mode. */ --=20 2.23.0 From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597770; cv=none; d=zohomail.com; s=zohoarc; b=RA+d5p12Jh5TJhj/OwaWYzrr6D/OIAUchylfOhgIYw6QUTtvn+A7pCHNJ7zHBZzenREKNIqpYsVgQVZFawfoD9pyL4BbwvAMDkIYE/8MJaG9YMGIckYrYtFaXR99b6/fHOvhIGBElEQyivI4WBgBAzf+ri+THVOaOAyLWGAejDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597770; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rlKRUoR0Gqa8EsNis6NSYbFTTnht9Aqg1T80NhjPYis=; b=IrYsHy6cPBRcpgPty3qab3jnODn/MTvNzcgnL9yU7678jIGc0jsFhau8EpYBPKbBfqs1NJvlshlTQJTRyNhvqmwLpod5cvO9w2YI1vuXYuGOyskp1HnHm/pQOmp+IMnHIHKVEprB0D2hlciZOk3YbuQM4vADpaMIpP1Nn/v86H4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159459777015860.44784924595558; Sun, 12 Jul 2020 16:49:30 -0700 (PDT) Received: from localhost ([::1]:38516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1juliq-0005sf-S7 for importer@patchew.org; Sun, 12 Jul 2020 19:49:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julfE-000745-Np for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:44 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:53046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007FV-S8 for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:44 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:29 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.326438|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.026057-0.000706032-0.973237; FP=0|0|0|0|0|-1|-1|-1; HT=e01a16367; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 6/8] fpu/softfloat: define operation for bfloat16 Date: Mon, 13 Jul 2020 07:45:19 +0800 Message-Id: <20200712234521.3972-7-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson --- fpu/softfloat.c | 146 +++++++++++++++++++++++++++++++++++++++- include/fpu/softfloat.h | 44 ++++++++++++ 2 files changed, 189 insertions(+), 1 deletion(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 54fc889446..9a58107be3 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1182,6 +1182,28 @@ float64_sub(float64 a, float64 b, float_status *s) return float64_addsub(a, b, s, hard_f64_sub, soft_f64_sub); } =20 +/* + * Returns the result of adding or subtracting the brain floating-point + * values `a' and `b'. + */ +bfloat16 QEMU_FLATTEN bfloat16_add(bfloat16 a, bfloat16 b, float_status *s= tatus) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, status); + FloatParts pb =3D bfloat16_unpack_canonical(b, status); + FloatParts pr =3D addsub_floats(pa, pb, false, status); + + return bfloat16_round_pack_canonical(pr, status); +} + +bfloat16 QEMU_FLATTEN bfloat16_sub(bfloat16 a, bfloat16 b, float_status *s= tatus) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, status); + FloatParts pb =3D bfloat16_unpack_canonical(b, status); + FloatParts pr =3D addsub_floats(pa, pb, true, status); + + return bfloat16_round_pack_canonical(pr, status); +} + /* * Returns the result of multiplying the floating-point values `a' and * `b'. The operation is performed according to the IEC/IEEE Standard @@ -1284,6 +1306,20 @@ float64_mul(float64 a, float64 b, float_status *s) f64_is_zon2, f64_addsubmul_post); } =20 +/* + * Returns the result of multiplying the brain floating-point + * values `a' and `b'. + */ + +bfloat16 QEMU_FLATTEN bfloat16_mul(bfloat16 a, bfloat16 b, float_status *s= tatus) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, status); + FloatParts pb =3D bfloat16_unpack_canonical(b, status); + FloatParts pr =3D mul_floats(pa, pb, status); + + return bfloat16_round_pack_canonical(pr, status); +} + /* * Returns the result of multiplying the floating-point values `a' and * `b' then adding 'c', with no intermediate rounding step after the @@ -1666,6 +1702,23 @@ float64_muladd(float64 xa, float64 xb, float64 xc, i= nt flags, float_status *s) return soft_f64_muladd(ua.s, ub.s, uc.s, flags, s); } =20 +/* + * Returns the result of multiplying the brain floating-point values `a' + * and `b' then adding 'c', with no intermediate rounding step after the + * multiplication. + */ + +bfloat16 QEMU_FLATTEN bfloat16_muladd(bfloat16 a, bfloat16 b, bfloat16 c, + int flags, float_status *status) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, status); + FloatParts pb =3D bfloat16_unpack_canonical(b, status); + FloatParts pc =3D bfloat16_unpack_canonical(c, status); + FloatParts pr =3D muladd_floats(pa, pb, pc, flags, status); + + return bfloat16_round_pack_canonical(pr, status); +} + /* * Returns the result of dividing the floating-point value `a' by the * corresponding value `b'. The operation is performed according to @@ -1832,6 +1885,20 @@ float64_div(float64 a, float64 b, float_status *s) f64_div_pre, f64_div_post); } =20 +/* + * Returns the result of dividing the brain floating-point + * value `a' by the corresponding value `b'. + */ + +bfloat16 bfloat16_div(bfloat16 a, bfloat16 b, float_status *status) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, status); + FloatParts pb =3D bfloat16_unpack_canonical(b, status); + FloatParts pr =3D div_floats(pa, pb, status); + + return bfloat16_round_pack_canonical(pr, status); +} + /* * Float to Float conversions * @@ -2871,6 +2938,25 @@ MINMAX(64, maxnummag, false, true, true) =20 #undef MINMAX =20 +#define BF16_MINMAX(name, ismin, isiee, ismag) \ +bfloat16 bfloat16_ ## name(bfloat16 a, bfloat16 b, float_status *s) \ +{ \ + FloatParts pa =3D bfloat16_unpack_canonical(a, s); \ + FloatParts pb =3D bfloat16_unpack_canonical(b, s); \ + FloatParts pr =3D minmax_floats(pa, pb, ismin, isiee, ismag, s); \ + \ + return bfloat16_round_pack_canonical(pr, s); \ +} + +BF16_MINMAX(min, true, false, false) +BF16_MINMAX(minnum, true, true, false) +BF16_MINMAX(minnummag, true, true, true) +BF16_MINMAX(max, false, false, false) +BF16_MINMAX(maxnum, false, true, false) +BF16_MINMAX(maxnummag, false, true, true) + +#undef BF16_MINMAX + /* Floating point compare */ static FloatRelation compare_floats(FloatParts a, FloatParts b, bool is_qu= iet, float_status *s) @@ -3032,6 +3118,24 @@ FloatRelation float64_compare_quiet(float64 a, float= 64 b, float_status *s) return f64_compare(a, b, true, s); } =20 +static int QEMU_FLATTEN +soft_bf16_compare(bfloat16 a, bfloat16 b, bool is_quiet, float_status *s) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, s); + FloatParts pb =3D bfloat16_unpack_canonical(b, s); + return compare_floats(pa, pb, is_quiet, s); +} + +int bfloat16_compare(bfloat16 a, bfloat16 b, float_status *s) +{ + return soft_bf16_compare(a, b, false, s); +} + +int bfloat16_compare_quiet(bfloat16 a, bfloat16 b, float_status *s) +{ + return soft_bf16_compare(a, b, true, s); +} + /* Multiply A by 2 raised to the power N. */ static FloatParts scalbn_decomposed(FloatParts a, int n, float_status *s) { @@ -3039,7 +3143,7 @@ static FloatParts scalbn_decomposed(FloatParts a, int= n, float_status *s) return return_nan(a, s); } if (a.cls =3D=3D float_class_normal) { - /* The largest float type (even though not supported by FloatParts) + /* The largest float type (even though nt supported by FloatParts) * is float128, which has a 15 bit exponent. Bounding N to 16 bits * still allows rounding to infinity, without allowing overflow * within the int32_t that backs FloatParts.exp. @@ -3071,6 +3175,13 @@ float64 float64_scalbn(float64 a, int n, float_statu= s *status) return float64_round_pack_canonical(pr, status); } =20 +bfloat16 bfloat16_scalbn(bfloat16 a, int n, float_status *status) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, status); + FloatParts pr =3D scalbn_decomposed(pa, n, status); + return bfloat16_round_pack_canonical(pr, status); +} + /* * Square Root * @@ -3221,6 +3332,13 @@ float64 QEMU_FLATTEN float64_sqrt(float64 xa, float_= status *s) return soft_f64_sqrt(ua.s, s); } =20 +bfloat16 QEMU_FLATTEN bfloat16_sqrt(bfloat16 a, float_status *status) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, status); + FloatParts pr =3D sqrt_float(pa, status, &bfloat16_params); + return bfloat16_round_pack_canonical(pr, status); +} + /*------------------------------------------------------------------------= ---- | The pattern for a default generated NaN. *-------------------------------------------------------------------------= ---*/ @@ -3263,6 +3381,13 @@ float128 float128_default_nan(float_status *status) return r; } =20 +bfloat16 bfloat16_default_nan(float_status *status) +{ + FloatParts p =3D parts_default_nan(status); + p.frac >>=3D bfloat16_params.frac_shift; + return bfloat16_pack_raw(p); +} + /*------------------------------------------------------------------------= ---- | Returns a quiet NaN from a signalling NaN for the floating point value `= a'. *-------------------------------------------------------------------------= ---*/ @@ -3294,6 +3419,14 @@ float64 float64_silence_nan(float64 a, float_status = *status) return float64_pack_raw(p); } =20 +bfloat16 bfloat16_silence_nan(bfloat16 a, float_status *status) +{ + FloatParts p =3D bfloat16_unpack_raw(a); + p.frac <<=3D bfloat16_params.frac_shift; + p =3D parts_silence_nan(p, status); + p.frac >>=3D bfloat16_params.frac_shift; + return bfloat16_pack_raw(p); +} =20 /*------------------------------------------------------------------------= ---- | If `a' is denormal and we are in flush-to-zero mode then set the @@ -3343,6 +3476,17 @@ float64 float64_squash_input_denormal(float64 a, flo= at_status *status) return a; } =20 +bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status) +{ + if (status->flush_inputs_to_zero) { + FloatParts p =3D bfloat16_unpack_raw(a); + if (parts_squash_denormal(p, status)) { + return bfloat16_set_sign(bfloat16_zero, p.sign); + } + } + return a; +} + /*------------------------------------------------------------------------= ---- | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 | and 7, and returns the properly rounded 32-bit integer corresponding to = the diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index ff4e2605b1..07020eafad 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -239,6 +239,37 @@ bool float16_is_quiet_nan(float16, float_status *statu= s); bool float16_is_signaling_nan(float16, float_status *status); float16 float16_silence_nan(float16, float_status *status); =20 +/*------------------------------------------------------------------------= ---- +| Software brain floatint-point operations. +*-------------------------------------------------------------------------= ---*/ + +bfloat16 bfloat16_add(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_sub(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_mul(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_div(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_muladd(bfloat16, bfloat16, bfloat16, int, + float_status *status); +float16 bfloat16_scalbn(bfloat16, int, float_status *status); +bfloat16 bfloat16_min(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_max(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_minnum(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_maxnum(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_minnummag(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_maxnummag(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_sqrt(bfloat16, float_status *status); +int bfloat16_compare(bfloat16, bfloat16, float_status *status); +int bfloat16_compare_quiet(bfloat16, bfloat16, float_status *status); +int bfloat16_unordered_quiet(bfloat16, bfloat16, float_status *status); +int bfloat16_le(bfloat16, bfloat16, float_status *status); +int bfloat16_lt(bfloat16, bfloat16, float_status *status); +int bfloat16_eq_quiet(bfloat16, bfloat16, float_status *status); + +int bfloat16_is_quiet_nan(bfloat16, float_status *status); +int bfloat16_is_signaling_nan(bfloat16, float_status *status); +bfloat16 bfloat16_silence_nan(bfloat16, float_status *status); +bfloat16 bfloat16_default_nan(float_status *status); +bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status); + static inline bool float16_is_any_nan(float16 a) { return ((float16_val(a) & ~0x8000) > 0x7c00); @@ -293,6 +324,19 @@ static inline float16 float16_set_sign(float16 a, int = sign) #define float16_three make_float16(0x4200) #define float16_infinity make_float16(0x7c00) =20 +static inline bfloat16 bfloat16_set_sign(bfloat16 a, int sign) +{ + return make_bfloat16((bfloat16_val(a) & 0x7fff) | (sign << 15)); +} + +#define bfloat16_zero make_bfloat16(0) +#define bfloat16_half make_bfloat16(0x3f00) +#define bfloat16_one make_bfloat16(0x3f80) +#define bfloat16_one_point_five make_bfloat16(0x3fc0) +#define bfloat16_two make_bfloat16(0x4000) +#define bfloat16_three make_bfloat16(0x4040) +#define bfloat16_infinity make_bfloat16(0x7f80) + /*------------------------------------------------------------------------= ---- | The pattern for a default generated half-precision NaN. *-------------------------------------------------------------------------= ---*/ --=20 2.23.0 From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597609; cv=none; d=zohomail.com; s=zohoarc; b=f/v3klDPF96BX4o+/BYyCOcaPgjrvBEvU77N5gRqU0HD5Jw0xnsboA9XTPcMKPKKDdYWCWMACJus0xaWnqyALtnMR5qJGszA3ppv/dkQQE8ucA7jYVGQ39SAg4WhhDRkg0yPx1NL8LZGqEHu7dT9c8GCj9Ka1/dqbyVOhIU8l8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597609; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iblRHhrTKSswBwGQ4TVl+njQC0pinJn5RvXLn5KPBBI=; b=d4ZMSaqIZe8yYMvuS1k1fYBtJBYM4Pnt8F0Ocq3kDXZR/uJTFm4l5kgl0Q6fxCM7259osgfxxkNHDkoPVogsUW/OWzMOqU+/zTFMbDJ1TqKaGfiULD1pSre0MkEUOrT5yzchMuI5cUlv8fL7bbBL2yPuRRSymAeT/t92qqaQgbY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594597608886302.0393682712447; Sun, 12 Jul 2020 16:46:48 -0700 (PDT) Received: from localhost ([::1]:52768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1julgF-0000F0-7K for importer@patchew.org; Sun, 12 Jul 2020 19:46:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julfA-00071l-26 for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:40 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:38583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007FZ-Hy for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:39 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:29 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07437594|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_alarm|0.116285-0.000824736-0.88289; FP=0|0|0|0|0|-1|-1|-1; HT=e01a16384; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 7/8] fpu/softfloat: define covert operation for bfloat16 Date: Mon, 13 Jul 2020 07:45:20 +0800 Message-Id: <20200712234521.3972-8-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson --- fpu/softfloat.c | 223 ++++++++++++++++++++++++++++++++++++++++ include/fpu/softfloat.h | 48 +++++++++ 2 files changed, 271 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 9a58107be3..b6002d6856 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2014,6 +2014,34 @@ float32 float64_to_float32(float64 a, float_status *= s) return float32_round_pack_canonical(pr, s); } =20 +float32 bfloat16_to_float32(bfloat16 a, float_status *s) +{ + FloatParts p =3D bfloat16_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, &float32_params, s); + return float32_round_pack_canonical(pr, s); +} + +float64 bfloat16_to_float64(bfloat16 a, float_status *s) +{ + FloatParts p =3D bfloat16_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, &float64_params, s); + return float64_round_pack_canonical(pr, s); +} + +bfloat16 float32_to_bfloat16(float32 a, float_status *s) +{ + FloatParts p =3D float32_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, &bfloat16_params, s); + return bfloat16_round_pack_canonical(pr, s); +} + +bfloat16 float64_to_bfloat16(float64 a, float_status *s) +{ + FloatParts p =3D float64_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, &bfloat16_params, s); + return bfloat16_round_pack_canonical(pr, s); +} + /* * Rounds the floating-point value `a' to an integer, and returns the * result as a floating-point value. The operation is performed @@ -2143,6 +2171,18 @@ float64 float64_round_to_int(float64 a, float_status= *s) return float64_round_pack_canonical(pr, s); } =20 +/* + * Rounds the brain floating-point value `a' to an integer, and returns the + * result as a brain floating-point value. + */ + +bfloat16 bfloat16_round_to_int(bfloat16 a, float_status *s) +{ + FloatParts pa =3D bfloat16_unpack_canonical(a, s); + FloatParts pr =3D round_to_int(pa, s->float_rounding_mode, 0, s); + return bfloat16_round_pack_canonical(pr, s); +} + /* * Returns the result of converting the floating-point value `a' to * the two's complement integer format. The conversion is performed @@ -2353,6 +2393,62 @@ int64_t float64_to_int64_round_to_zero(float64 a, fl= oat_status *s) return float64_to_int64_scalbn(a, float_round_to_zero, 0, s); } =20 +/* + * Returns the result of converting the floating-point value `a' to + * the two's complement integer format. + */ + +int16_t bfloat16_to_int16_scalbn(bfloat16 a, int rmode, int scale, + float_status *s) +{ + return round_to_int_and_pack(bfloat16_unpack_canonical(a, s), + rmode, scale, INT16_MIN, INT16_MAX, s); +} + +int32_t bfloat16_to_int32_scalbn(bfloat16 a, int rmode, int scale, + float_status *s) +{ + return round_to_int_and_pack(bfloat16_unpack_canonical(a, s), + rmode, scale, INT32_MIN, INT32_MAX, s); +} + +int64_t bfloat16_to_int64_scalbn(bfloat16 a, int rmode, int scale, + float_status *s) +{ + return round_to_int_and_pack(bfloat16_unpack_canonical(a, s), + rmode, scale, INT64_MIN, INT64_MAX, s); +} + +int16_t bfloat16_to_int16(bfloat16 a, float_status *s) +{ + return bfloat16_to_int16_scalbn(a, s->float_rounding_mode, 0, s); +} + +int32_t bfloat16_to_int32(bfloat16 a, float_status *s) +{ + return bfloat16_to_int32_scalbn(a, s->float_rounding_mode, 0, s); +} + +int64_t bfloat16_to_int64(bfloat16 a, float_status *s) +{ + return bfloat16_to_int64_scalbn(a, s->float_rounding_mode, 0, s); +} + +int16_t bfloat16_to_int16_round_to_zero(bfloat16 a, float_status *s) +{ + return bfloat16_to_int16_scalbn(a, float_round_to_zero, 0, s); +} + +int32_t bfloat16_to_int32_round_to_zero(bfloat16 a, float_status *s) +{ + return bfloat16_to_int32_scalbn(a, float_round_to_zero, 0, s); +} + +int64_t bfloat16_to_int64_round_to_zero(bfloat16 a, float_status *s) +{ + return bfloat16_to_int64_scalbn(a, float_round_to_zero, 0, s); +} + /* * Returns the result of converting the floating-point value `a' to * the unsigned integer format. The conversion is performed according @@ -2566,6 +2662,62 @@ uint64_t float64_to_uint64_round_to_zero(float64 a, = float_status *s) return float64_to_uint64_scalbn(a, float_round_to_zero, 0, s); } =20 +/* + * Returns the result of converting the brain floating-point value `a' to + * the unsigned integer format. + */ + +uint16_t bfloat16_to_uint16_scalbn(bfloat16 a, int rmode, int scale, + float_status *s) +{ + return round_to_uint_and_pack(bfloat16_unpack_canonical(a, s), + rmode, scale, UINT16_MAX, s); +} + +uint32_t bfloat16_to_uint32_scalbn(bfloat16 a, int rmode, int scale, + float_status *s) +{ + return round_to_uint_and_pack(bfloat16_unpack_canonical(a, s), + rmode, scale, UINT32_MAX, s); +} + +uint64_t bfloat16_to_uint64_scalbn(bfloat16 a, int rmode, int scale, + float_status *s) +{ + return round_to_uint_and_pack(bfloat16_unpack_canonical(a, s), + rmode, scale, UINT64_MAX, s); +} + +uint16_t bfloat16_to_uint16(bfloat16 a, float_status *s) +{ + return bfloat16_to_uint16_scalbn(a, s->float_rounding_mode, 0, s); +} + +uint32_t bfloat16_to_uint32(bfloat16 a, float_status *s) +{ + return bfloat16_to_uint32_scalbn(a, s->float_rounding_mode, 0, s); +} + +uint64_t bfloat16_to_uint64(bfloat16 a, float_status *s) +{ + return bfloat16_to_uint64_scalbn(a, s->float_rounding_mode, 0, s); +} + +uint16_t bfloat16_to_uint16_round_to_zero(bfloat16 a, float_status *s) +{ + return bfloat16_to_uint16_scalbn(a, float_round_to_zero, 0, s); +} + +uint32_t bfloat16_to_uint32_round_to_zero(bfloat16 a, float_status *s) +{ + return bfloat16_to_uint32_scalbn(a, float_round_to_zero, 0, s); +} + +uint64_t bfloat16_to_uint64_round_to_zero(bfloat16 a, float_status *s) +{ + return bfloat16_to_uint64_scalbn(a, float_round_to_zero, 0, s); +} + /* * Integer to float conversions * @@ -2692,6 +2844,41 @@ float64 int16_to_float64(int16_t a, float_status *st= atus) return int64_to_float64_scalbn(a, 0, status); } =20 +/* + * Returns the result of converting the two's complement integer `a' + * to the brain floating-point format. + */ + +bfloat16 int64_to_bfloat16_scalbn(int64_t a, int scale, float_status *stat= us) +{ + FloatParts pa =3D int_to_float(a, scale, status); + return bfloat16_round_pack_canonical(pa, status); +} + +bfloat16 int32_to_bfloat16_scalbn(int32_t a, int scale, float_status *stat= us) +{ + return int64_to_bfloat16_scalbn(a, scale, status); +} + +bfloat16 int16_to_bfloat16_scalbn(int16_t a, int scale, float_status *stat= us) +{ + return int64_to_bfloat16_scalbn(a, scale, status); +} + +bfloat16 int64_to_bfloat16(int64_t a, float_status *status) +{ + return int64_to_bfloat16_scalbn(a, 0, status); +} + +bfloat16 int32_to_bfloat16(int32_t a, float_status *status) +{ + return int64_to_bfloat16_scalbn(a, 0, status); +} + +bfloat16 int16_to_bfloat16(int16_t a, float_status *status) +{ + return int64_to_bfloat16_scalbn(a, 0, status); +} =20 /* * Unsigned Integer to float conversions @@ -2817,6 +3004,42 @@ float64 uint16_to_float64(uint16_t a, float_status *= status) return uint64_to_float64_scalbn(a, 0, status); } =20 +/* + * Returns the result of converting the unsigned integer `a' to the + * brain floating-point format. + */ + +bfloat16 uint64_to_bfloat16_scalbn(uint64_t a, int scale, float_status *st= atus) +{ + FloatParts pa =3D uint_to_float(a, scale, status); + return bfloat16_round_pack_canonical(pa, status); +} + +bfloat16 uint32_to_bfloat16_scalbn(uint32_t a, int scale, float_status *st= atus) +{ + return uint64_to_bfloat16_scalbn(a, scale, status); +} + +bfloat16 uint16_to_bfloat16_scalbn(uint16_t a, int scale, float_status *st= atus) +{ + return uint64_to_bfloat16_scalbn(a, scale, status); +} + +bfloat16 uint64_to_bfloat16(uint64_t a, float_status *status) +{ + return uint64_to_bfloat16_scalbn(a, 0, status); +} + +bfloat16 uint32_to_bfloat16(uint32_t a, float_status *status) +{ + return uint64_to_bfloat16_scalbn(a, 0, status); +} + +bfloat16 uint16_to_bfloat16(uint16_t a, float_status *status) +{ + return uint64_to_bfloat16_scalbn(a, 0, status); +} + /* Float Min/Max */ /* min() and max() functions. These can't be implemented as * 'compare and pick one input' because that would mishandle diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 07020eafad..6590850253 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -270,6 +270,54 @@ bfloat16 bfloat16_silence_nan(bfloat16, float_status *= status); bfloat16 bfloat16_default_nan(float_status *status); bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status); =20 +/*------------------------------------------------------------------------= ---- +| Software brain floating-point conversion routines. +*-------------------------------------------------------------------------= ---*/ + +bfloat16 bfloat16_round_to_int(bfloat16, float_status *status); +bfloat16 float32_to_bfloat16(float32, float_status *status); +float32 bfloat16_to_float32(bfloat16, float_status *status); +bfloat16 float64_to_bfloat16(float64 a, float_status *status); +float64 bfloat16_to_float64(bfloat16 a, float_status *status); + +int16_t bfloat16_to_int16_scalbn(bfloat16, int, int, float_status *status); +int32_t bfloat16_to_int32_scalbn(bfloat16, int, int, float_status *status); +int64_t bfloat16_to_int64_scalbn(bfloat16, int, int, float_status *status); + +int16_t bfloat16_to_int16(bfloat16, float_status *status); +int32_t bfloat16_to_int32(bfloat16, float_status *status); +int64_t bfloat16_to_int64(bfloat16, float_status *status); + +int16_t bfloat16_to_int16_round_to_zero(bfloat16, float_status *status); +int32_t bfloat16_to_int32_round_to_zero(bfloat16, float_status *status); +int64_t bfloat16_to_int64_round_to_zero(bfloat16, float_status *status); + +uint16_t bfloat16_to_uint16_scalbn(bfloat16 a, int, int, float_status *sta= tus); +uint32_t bfloat16_to_uint32_scalbn(bfloat16 a, int, int, float_status *sta= tus); +uint64_t bfloat16_to_uint64_scalbn(bfloat16 a, int, int, float_status *sta= tus); + +uint16_t bfloat16_to_uint16(bfloat16 a, float_status *status); +uint32_t bfloat16_to_uint32(bfloat16 a, float_status *status); +uint64_t bfloat16_to_uint64(bfloat16 a, float_status *status); + +uint16_t bfloat16_to_uint16_round_to_zero(bfloat16 a, float_status *status= ); +uint32_t bfloat16_to_uint32_round_to_zero(bfloat16 a, float_status *status= ); +uint64_t bfloat16_to_uint64_round_to_zero(bfloat16 a, float_status *status= ); + +bfloat16 int16_to_bfloat16_scalbn(int16_t a, int, float_status *status); +bfloat16 int32_to_bfloat16_scalbn(int32_t a, int, float_status *status); +bfloat16 int64_to_bfloat16_scalbn(int64_t a, int, float_status *status); +bfloat16 uint16_to_bfloat16_scalbn(uint16_t a, int, float_status *status); +bfloat16 uint32_to_bfloat16_scalbn(uint32_t a, int, float_status *status); +bfloat16 uint64_to_bfloat16_scalbn(uint64_t a, int, float_status *status); + +bfloat16 int16_to_bfloat16(int16_t a, float_status *status); +bfloat16 int32_to_bfloat16(int32_t a, float_status *status); +bfloat16 int64_to_bfloat16(int64_t a, float_status *status); +bfloat16 uint16_to_bfloat16(uint16_t a, float_status *status); +bfloat16 uint32_to_bfloat16(uint32_t a, float_status *status); +bfloat16 uint64_to_bfloat16(uint64_t a, float_status *status); + static inline bool float16_is_any_nan(float16 a) { return ((float16_val(a) & ~0x8000) > 0x7c00); --=20 2.23.0 From nobody Sat May 18 10:07:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594597611; cv=none; d=zohomail.com; s=zohoarc; b=L19pIFRFC1RcPVyLp346iGj53oeXlbbID3rMDuuQ4U2UIB4AbhgME5GBKS+oTaBz6qoJceNrhoXJe34l39ul9nIR+nCI64aUXYItDNE8/wPCroG01T+AQHpdk8HGBI2Y3T3bM/SinLCIqa4Vprrt+EO4+4ylGlYPzt3BeWxQ7Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594597611; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6SpCNENABMuJbB043rAbsdWoMVIVIjyPJ8Qw5U5wj70=; b=E60+CSUgkEVE3oV8Bdbc6aTOHReYAfvCoi/ZMikWoCvMJkj9g60aSKe4IpvnBEnnYQheG4oM8GfY62fcoZQZoMcxAN8sIS9+WeCywee9QpWNpJckkxslJw1AKHDL88GEoNH1jjQ/F9L6TIFO9kckNbQRqoFmlXwIFICCUQJb3pA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594597611252251.59166200845084; Sun, 12 Jul 2020 16:46:51 -0700 (PDT) Received: from localhost ([::1]:53006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1julgH-0000LC-Rn for importer@patchew.org; Sun, 12 Jul 2020 19:46:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julfC-00072P-Cm for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:42 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:37259) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1julf6-0007Fo-SS for qemu-devel@nongnu.org; Sun, 12 Jul 2020 19:45:42 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.I0oni3i_1594597526) by smtp.aliyun-inc.com(10.147.40.7); Mon, 13 Jul 2020 07:45:30 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07634485|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.0985976-0.002253-0.899149; FP=0|0|0|0|0|-1|-1|-1; HT=e01a16378; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=6; RT=6; SR=0; TI=SMTPD_---.I0oni3i_1594597526; From: LIU Zhiwei To: qemu-devel@nongnu.org Subject: [RFC PATCH 8/8] fpu/softfloat: define misc operation for bfloat16 Date: Mon, 13 Jul 2020 07:45:21 +0800 Message-Id: <20200712234521.3972-9-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200712234521.3972-1-zhiwei_liu@c-sky.com> References: <20200712234521.3972-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=121.197.200.217; envelope-from=zhiwei_liu@c-sky.com; helo=smtp2200-217.mail.aliyun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 19:45:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org, wenmeng_zhang@c-sky.com, richard.henderson@linaro.org, LIU Zhiwei , wxy194768@alibaba-inc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson --- fpu/softfloat-specialize.inc.c | 38 +++++++++++++++++++++++++++++++ include/fpu/softfloat.h | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/fpu/softfloat-specialize.inc.c b/fpu/softfloat-specialize.inc.c index 6b778a7830..ff17f11f0c 100644 --- a/fpu/softfloat-specialize.inc.c +++ b/fpu/softfloat-specialize.inc.c @@ -259,6 +259,25 @@ bool float16_is_quiet_nan(float16 a_, float_status *st= atus) #endif } =20 +/*------------------------------------------------------------------------= ---- +| Returns 1 if the brain floating point value `a' is a quiet +| NaN; otherwise returns 0. +*-------------------------------------------------------------------------= ---*/ + +int bfloat16_is_quiet_nan(bfloat16 a_, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + return bfloat16_is_any_nan(a_); +#else + uint16_t a =3D bfloat16_val(a_); + if (snan_bit_is_one(status)) { + return (((a >> 6) & 0x1FF) =3D=3D 0x1FE) && (a & 0x3F); + } else { + return ((a >> 6) & 0x1FF) =3D=3D 0x1FF; + } +#endif +} + /*------------------------------------------------------------------------= ---- | Returns 1 if the half-precision floating-point value `a' is a signaling | NaN; otherwise returns 0. @@ -278,6 +297,25 @@ bool float16_is_signaling_nan(float16 a_, float_status= *status) #endif } =20 +/*------------------------------------------------------------------------= ---- +| Returns 1 if the brain floating point value `a' is a signaling +| NaN; otherwise returns 0. +*-------------------------------------------------------------------------= ---*/ + +int bfloat16_is_signaling_nan(bfloat16 a_, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + return 0; +#else + uint16_t a =3D bfloat16_val(a_); + if (snan_bit_is_one(status)) { + return ((a >> 6) & 0x1FF) =3D=3D 0x1FF; + } else { + return (((a >> 6) & 0x1FF) =3D=3D 0x1FE) && (a & 0x3F); + } +#endif +} + /*------------------------------------------------------------------------= ---- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 6590850253..d2c3f5fbe0 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -372,6 +372,47 @@ static inline float16 float16_set_sign(float16 a, int = sign) #define float16_three make_float16(0x4200) #define float16_infinity make_float16(0x7c00) =20 +static inline int bfloat16_is_any_nan(bfloat16 a) +{ + return ((bfloat16_val(a) & ~0x8000) > 0x7F80); +} + +static inline int bfloat16_is_neg(bfloat16 a) +{ + return bfloat16_val(a) >> 15; +} + +static inline int bfloat16_is_infinity(bfloat16 a) +{ + return (bfloat16_val(a) & 0x7fff) =3D=3D 0x7F80; +} + +static inline int bfloat16_is_zero(bfloat16 a) +{ + return (bfloat16_val(a) & 0x7fff) =3D=3D 0; +} + +static inline int bfloat16_is_zero_or_denormal(bfloat16 a) +{ + return (bfloat16_val(a) & 0x7F80) =3D=3D 0; +} + +static inline bfloat16 bfloat16_abs(bfloat16 a) +{ + /* Note that abs does *not* handle NaN specially, nor does + * it flush denormal inputs to zero. + */ + return make_bfloat16(bfloat16_val(a) & 0x7fff); +} + +static inline bfloat16 bfloat16_chs(bfloat16 a) +{ + /* Note that chs does *not* handle NaN specially, nor does + * it flush denormal inputs to zero. + */ + return make_bfloat16(bfloat16_val(a) ^ 0x8000); +} + static inline bfloat16 bfloat16_set_sign(bfloat16 a, int sign) { return make_bfloat16((bfloat16_val(a) & 0x7fff) | (sign << 15)); --=20 2.23.0