This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch 2/4] [libgcc] Add double to half conversions.
- From: James Greenhalgh <james dot greenhalgh at arm dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: <nd at arm dot com>, <richard dot earnshaw at arm dot com>, <ramana dot radhakrishnan at arm dot com>, <kyrtka01 at arm dot com>, <joseph at codesourcery dot com>
- Date: Mon, 24 Oct 2016 14:44:38 +0100
- Subject: [Patch 2/4] [libgcc] Add double to half conversions.
- Authentication-results: sourceware.org; auth=none
- Nodisclaimer: True
- References: <1475254617-10825-1-git-send-email-james.greenhalgh@arm.com> <1477316680-5094-1-git-send-email-james.greenhalgh@arm.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi,
Conversions from double precision floats to the ARM __fp16 are required
to round only once.
This patch adds a functions named __gnu_d2h_ieee and
__gnu_d2h_alternative for double to __fp16 conversions in IEEE and ARM
alternative format. The make use of the existing __gnu_float2h_internal
conversion function which rounds once only.
Bootstrapped on an ARMv8-A machine with no issues, and cross-tested with
a range of multilibs.
OK?
Thanks,
James
---
libgcc/
2016-10-24 James Greenhalgh <james.greenhalgh@arm.com>
Matthew Wahab <matthew.wahab@arm.com>
* config/arm/fp16.c (binary64): New.
(__gnu_d2h_internal): New.
(__gnu_d2h_ieee): New.
(__gnu_d2h_alternative): New.
diff --git a/libgcc/config/arm/fp16.c b/libgcc/config/arm/fp16.c
index 8d02a24..48c4f9c 100644
--- a/libgcc/config/arm/fp16.c
+++ b/libgcc/config/arm/fp16.c
@@ -43,6 +43,15 @@ binary32 =
23 /* significand. */
};
+static const struct format
+binary64 =
+{
+ 64, /* size. */
+ 1023, /* bias. */
+ 11, /* exponent. */
+ 52 /* significand. */
+};
+
static inline unsigned short
__gnu_float2h_internal (const struct format* fmt,
unsigned long long a, int ieee)
@@ -136,6 +145,12 @@ __gnu_f2h_internal (unsigned int a, int ieee)
return __gnu_float2h_internal (&binary32, (unsigned long long) a, ieee);
}
+static inline unsigned short
+__gnu_d2h_internal (unsigned long long a, int ieee)
+{
+ return __gnu_float2h_internal (&binary64, a, ieee);
+}
+
unsigned int
__gnu_h2f_internal(unsigned short a, int ieee)
{
@@ -184,3 +199,15 @@ __gnu_h2f_alternative(unsigned short a)
{
return __gnu_h2f_internal(a, 0);
}
+
+unsigned short
+__gnu_d2h_ieee (unsigned long long a)
+{
+ return __gnu_d2h_internal (a, 1);
+}
+
+unsigned short
+__gnu_d2h_alternative (unsigned long long x)
+{
+ return __gnu_d2h_internal (x, 0);
+}