Subject: Re: cross-compiler to VAX outputs bogus float literals.
To: Anders Magnusson <ragge@ludd.luth.se>
From: Todd Whitesel <toddpw@best.com>
List: tech-toolchain
Date: 02/06/2000 04:08:50
> I don't really remember; it was a define somewhere in one of the vax
> description files in gcc. There were a comment also that said that it must
> be turned on when making vax cross-compilers. I haven't made any cross-
> compiler since gcc 2.7.2, but back then it was there at least.

Yep:

/* Define for software floating point emulation of VAX format
   when cross compiling from a non-VAX host. */
/* #define REAL_ARITHMETIC */

I found it earlier today, by scouring config/vax looking for clues.
I actually found REAL_VALUE_TO_DECIMAL first, but from there it was
just a short grep-hunt.

I note that when this is defined, code like this:

#define ASM_OUTPUT_DOUBLE(FILE,VALUE)  \
do { char dstr[30];                                                     \
     REAL_VALUE_TO_DECIMAL (VALUE, "%.20e", dstr);                      \
     fprintf (FILE, "\t.%cfloat 0%c%s\n", ASM_DOUBLE_CHAR,              \
                                          ASM_DOUBLE_CHAR, dstr);       \
   } while (0); 

... invokes a macro which does this:

/* Conversions to decimal ASCII string.  */
#define REAL_VALUE_TO_DECIMAL(r, fmt, s) (ereal_to_decimal (r, s))

... why this is dangerous should be obvious by inspection, and is probably
why the code is not automatically enabled any time the target format is vax
but the host format is not.

With it enabled, I get slightly different output (ex. libm n_acosh.c):

23c23
<       movd $0d1.00000000000000000000e+20,-16(fp)
---
>       movd $0d1.00000000000000000000e20,-16(fp)
33c33
<       subd3 $0d1.00000000000000000000e+00,4(ap),r0
---
>       subd3 $0d1.00000000000000000000e0,4(ap),r0
37c37
<       addd3 4(ap),$0d1.00000000000000000000e+00,r0
---
>       addd3 4(ap),$0d1.00000000000000000000e0,r0

... but it is accepted by the assembler and the object files are identical.

Problem solved, thanks guys!

Todd Whitesel
toddpw @ best.com