This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
GAS support for an IEEE variation
- To: <binutils at sources dot redhat dot com>
- Subject: GAS support for an IEEE variation
- From: Richard Sandiford <rsandifo at redhat dot com>
- Date: Fri, 2 Mar 2001 13:54:30 +0000 (GMT)
I recently needed GAS to support a variation of the IEEE standard
in which the largest exponent could be used for normal numbers instead
of NaNs. This patch adds a target option TC_LARGEST_EXPONENT_IS_NORMAL,
that can be defined to select this kind of format.
Please install if OK.
Richard
2001-03-02 Richard Sandiford <rsandifo@redhat.com>
* config/atof-ieee.c (TC_LARGEST_EXPONENT_IS_NORMAL): New macro.
(gen_to_words): Print warnings if NaNs are found and the target CPU
does not support them. Allow largest exponent to be used in normal
numbers if TC_LARGEST_EXPONENT_IS_NORMAL evaluates to true.
Index: ./gas/config/atof-ieee.c
===================================================================
RCS file: /cvs/src/src/gas/config/atof-ieee.c,v
retrieving revision 1.6
diff -c -p -d -r1.6 atof-ieee.c
*** ./gas/config/atof-ieee.c 2000/08/07 19:54:34 1.6
--- ./gas/config/atof-ieee.c 2001/03/02 13:48:05
***************
*** 1,5 ****
/* atof_ieee.c - turn a Flonum into an IEEE floating point number
! Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
--- 1,5 ----
/* atof_ieee.c - turn a Flonum into an IEEE floating point number
! Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
***************
*** 19,24 ****
--- 19,31 ----
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
+ /* Some float formats are based on the IEEE standard, but use the
+ largest exponent for normal numbers instead of NaNs and infinites.
+ The macro TC_LARGEST_EXPONENT_IS_NORMAL should evaluate to true
+ if the target machine uses such a format. The macro can depend on
+ command line flags if necessary. There is no need to define the
+ macro if it would always be 0. */
+
#include "as.h"
/* Flonums returned here. */
*************** extern const char EXP_CHARS[];
*** 40,45 ****
--- 47,56 ----
/* Length in LittleNums of guard bits. */
#define GUARD (2)
+ #ifndef TC_LARGEST_EXPONENT_IS_NORMAL
+ #define TC_LARGEST_EXPONENT_IS_NORMAL 0
+ #endif
+
static const unsigned long mask[] =
{
0x00000000,
*************** gen_to_words (words, precision, exponent
*** 291,296 ****
--- 302,309 ----
/* NaN: Do the right thing. */
if (generic_floating_point_number.sign == 0)
{
+ if (TC_LARGEST_EXPONENT_IS_NORMAL)
+ as_warn ("NaNs are not supported by this target\n");
if (precision == F_PRECISION)
{
words[0] = 0x7fff;
*************** gen_to_words (words, precision, exponent
*** 328,333 ****
--- 341,349 ----
}
else if (generic_floating_point_number.sign == 'P')
{
+ if (TC_LARGEST_EXPONENT_IS_NORMAL)
+ as_warn ("Infinities are not supported by this target\n");
+
/* +INF: Do the right thing. */
if (precision == F_PRECISION)
{
*************** gen_to_words (words, precision, exponent
*** 366,371 ****
--- 382,390 ----
}
else if (generic_floating_point_number.sign == 'N')
{
+ if (TC_LARGEST_EXPONENT_IS_NORMAL)
+ as_warn ("Infinities are not supported by this target\n");
+
/* Negative INF. */
if (precision == F_PRECISION)
{
*************** gen_to_words (words, precision, exponent
*** 578,584 ****
return return_value;
}
! else if ((unsigned long) exponent_4 >= mask[exponent_bits])
{
/* Exponent overflow. Lose immediately. */
--- 597,605 ----
return return_value;
}
! else if ((unsigned long) exponent_4 > mask[exponent_bits]
! || (! TC_LARGEST_EXPONENT_IS_NORMAL
! && (unsigned long) exponent_4 == mask[exponent_bits]))
{
/* Exponent overflow. Lose immediately. */