From nobody Wed Feb 11 05:13:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152648709193955.89994291305413; Wed, 16 May 2018 09:11:31 -0700 (PDT) Received: from localhost ([::1]:53234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz1X-00029L-4t for importer@patchew.org; Wed, 16 May 2018 12:11:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjg-0004QK-GJ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjf-000543-Fq for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:04 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:39364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjf-00053u-9a for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:03 -0400 Received: by mail-pl0-x242.google.com with SMTP id c19-v6so668338pls.6 for ; Wed, 16 May 2018 08:53:03 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:00 -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=lRqGxJhzFUeyacxzleC4RhsXXY0zMiUoKTM/DfcJ4HY=; b=U0diJaEsVeqqZQGIRT7SSZ86E4EFLxgl+pVZKJ6CDJf/G7zTqdvv/e39Kv/hFKv4O9 am9Q8V+DWf3dvenlR3DGpVZhrfetGTGQbIrovPTCbiM8T6NZa4T/Avjiy/ma2YPdcAZ7 QsfhHyVYTj8Lm7El63C3I38E721Tzj1mqjIoA= 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=lRqGxJhzFUeyacxzleC4RhsXXY0zMiUoKTM/DfcJ4HY=; b=U7IqW7+co0MKn8VGLOeDlgl3cJVfkdSHoW+FucCu5BcdxXwTjJYvQJvWHnoHF7PTQ5 CVLEkBOer0VM3krI4Ed243qAS+QqcpbTkTyGypd6pjsx5q1jlItqQbr5wDGR3sG5+SvT 9K9bpRM2Y+KDpo7J54z0bs8NNpTsfUa9eRJH5otP6QVvNSjEsbfQ9JN83wqOR4Wqd7ry UCx/EJ5/+WaRgOPbM0sgUmU6rtFnTJQ1CpWpWoVRnyqy8pOmOX7rBBB6J5iY6jovGFVI pNpWICZe6Q8O+BbfwO04PwRgih/sR5ATFle7ZAyaFcMufY7q0t7U+9zr90JJWBaOMmF6 r3pw== X-Gm-Message-State: ALKqPwds11t8kINoMKdchr1hIBmL0BjwMAOTDoxg2/8ltBv0/+AOB8IY yRS1VD98tCTCdCdJDL5Wgze2Q6dxPGg= X-Google-Smtp-Source: AB8JxZoVScNN1zRJueG6wu+jA0KGMi+e8VCs07941Y+89jc+J2TxJqR/huxP9NDvSLS2WeztFuDJSQ== X-Received: by 2002:a17:902:6006:: with SMTP id r6-v6mr1463603plj.70.1526485981937; Wed, 16 May 2018 08:53:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:26 -0700 Message-Id: <20180516155243.16937-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PULL 11/28] fpu/softfloat: Partial support for ARM Alternative half-precision 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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e For float16 ARM supports an alternative half-precision format which sacrifices the ability to represent NaN/Inf in return for a higher dynamic range. The new FloatFmt flag, arm_althp, is then used to modify the behaviour of canonicalize and round_canonical with respect to representation and exception raising. Usage of this new flag waits until we re-factor float-to-float conversions. Reviewed-by: Peter Maydell Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- fpu/softfloat.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 41253c6749..64e1ad4f98 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -220,8 +220,10 @@ typedef struct { * frac_shift: shift to normalise the fraction with DECOMPOSED_BINARY_PO= INT * The following are computed based the size of fraction * frac_lsb: least significant bit of fraction - * fram_lsbm1: the bit bellow the least significant bit (for rounding) + * frac_lsbm1: the bit below the least significant bit (for rounding) * round_mask/roundeven_mask: masks used for rounding + * The following optional modifiers are available: + * arm_althp: handle ARM Alternative Half Precision */ typedef struct { int exp_size; @@ -233,6 +235,7 @@ typedef struct { uint64_t frac_lsbm1; uint64_t round_mask; uint64_t roundeven_mask; + bool arm_althp; } FloatFmt; =20 /* Expand fields based on the size of exponent and fraction */ @@ -324,7 +327,7 @@ static inline float64 float64_pack_raw(FloatParts p) static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, float_status *status) { - if (part.exp =3D=3D parm->exp_max) { + if (part.exp =3D=3D parm->exp_max && !parm->arm_althp) { if (part.frac =3D=3D 0) { part.cls =3D float_class_inf; } else { @@ -413,7 +416,15 @@ static FloatParts round_canonical(FloatParts p, float_= status *s, } frac >>=3D frac_shift; =20 - if (unlikely(exp >=3D exp_max)) { + if (parm->arm_althp) { + /* ARM Alt HP eschews Inf and NaN for a wider exponent. */ + if (unlikely(exp > exp_max)) { + /* Overflow. Return the maximum normal. */ + flags =3D float_flag_invalid; + exp =3D exp_max; + frac =3D -1; + } + } else if (unlikely(exp >=3D exp_max)) { flags |=3D float_flag_overflow | float_flag_inexact; if (overflow_norm) { exp =3D exp_max - 1; @@ -464,12 +475,14 @@ static FloatParts round_canonical(FloatParts p, float= _status *s, =20 case float_class_inf: do_inf: + assert(!parm->arm_althp); exp =3D exp_max; frac =3D 0; break; =20 case float_class_qnan: case float_class_snan: + assert(!parm->arm_althp); exp =3D exp_max; frac >>=3D parm->frac_shift; break; --=20 2.17.0