[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Directions for gcc + gnat + software FP for x86
- Date: Sat, 27 Feb 1999 16:06:01 -0800 (PST)
- From: tonya at ece.ubc.ca (Tony R. Ambardar)
- Subject: Directions for gcc + gnat + software FP for x86
I was planning to submit much of this information along with a new BSP
when it was ready, but since there seems to be some interest I'll try to
go over things now. These are basically the steps I took to build
GCC-2.8.1 and GNAT-3.11p targetted to an i386 with software floating-point
emulation. My build host is a P133 running Linux Redhat 5.2.
It's been a little while since I rebuilt these tools, so I'd appreciate
hearing if this recipe works...
1) Unarchive and patch all the tool sources as per the directions in the
"Getting Started with ..." guides, with the following exceptions.
a) Use the GNAT-3.11p sources instead of GNAT-3.10p.
b) DO NOT apply the RTEMS patch for GNAT-3.10p.
c) GNAT-3.11p includes it's own patches for gcc-2.8.1, etc. Apply these.
There will be some fuzz, but no rejections I can remember. Note: I
did not apply the gdb patch supplied with GNAT-3.11p.
2) In the tools/gcc-2.8.1 directory, apply the two attached patches:
a) gcc-2.8.1-softfloat.patch enables software floating point emulation
in GCC and allows automatic building of software FP versions of
newlib and GCC's libs (via GCC's MULTILIB).
b) gnat-3.11p-softfloat.patch modifies GNAT's runtime so that the type
Long_Long_Float (equivalent to C's long double) is the same as the
type Long_Float (equivalent to C's double). This is needed for three
reasons:
i) The software floating point emulation provides only stubs for
"long double" (i.e. 80-bit float) routines.
ii) GNAT-3.11 will fail compiling parts of the runtime that use
Long_Long_Float types. GNAT/GCC seems to run out of registers...
iii) A working Long_Long_Float type is needed throughout the runtime
for things such as printing all floating-point numbers.
3) Two more build/configuration files must be modified:
a) In the tools/rtems-4.0.0/make/custom/ directory, edit the '.cfg' file
for your BSP. To the CPU_CFLAGS variable add the following options
(without quotes): "-msoft-float -mno-fp-ret-in-387". This ensures
that RTEMS is built with software FP support.
b) Edit the bit_ada script. Find the code that builds the GNAT runtime
libraries and add the options "-msoft-float -mno-fp-ret-in-387" to
the variable GNATLIBFLAGS. This is necessary because GNAT does not
support GCC's MULTILIB feature.
4) Run bit_ada and bit_rtems as usual. Run the paranoia test on your
board. Run an Ada program that prints a floating point variable. If
these both succeed, then celebrate!
Good luck,
Tony Ambardar
____________________________________________________________
/ \
| Tony R. Ambardar | Department of Electrical & |
| M.Eng. Student | Computer Engineering |
| Email: tonya at ece.ubc.ca | University of British Columbia |
| Ph: (604) 822-3611 | 2356 Main Mall, Vancouver B.C. |
| Fax:(604) 822-5949 | V6T 1Z4 CANADA |
\____________________________________________________________/
On Thu, 25 Feb 1999 joel at OARcorp.com wrote:
> On Thu, 25 Feb 1999, Tony R. Ambardar wrote:
> >
> > I just wanted to point out that GCC *does* in fact support software
> > floating-point emulation for ix86's without hardware FP. The required code
> > is present but disabled by default, though the changes necessary to enable
> > it are minimal.
>
> Thank you for this information. I would encourage you to submit your
> patch to enable this for embedded i386 target configurations. Please cc
> me on the patch and I will add it to the RTEMS patches.
>
> > I am currently using software floating-point for GCC+GNAT with a new
> > i386-based BSP I'm working on. It works with several examples I've tried,
> > and also passes the paranoia floating-point test included with RTEMS. To
> > be honest, getting GNAT to do this was much more of a pain than GCC.
>
> :) No one said GNAT was easy to build.
>
> Please give the list some information on your success. We all like to
> share. if there is anything that can be learned from your experience that
> can prevent someone from suffering in the future.
>
-------------- next part --------------
*** config/i386/rtems.h Wed Feb 17 22:22:32 1999
--- config/i386/rtems.h Wed Feb 17 22:24:23 1999
***************
*** 32,35 ****
--- 32,39 ----
#define TARGET_MEM_FUNCTIONS
#endif
+ /* Try to make types long double and double the same */
+ #undef LONG_DOUBLE_TYPE_SIZE
+ #define LONG_DOUBLE_TYPE_SIZE 64
+
/* end of i386/rtems.h */
*** ada/ttypef.ads Thu Feb 18 23:12:09 1999
--- ada/ttypef.ads Thu Feb 18 23:16:18 1999
***************
*** 50,112 ****
IEEES_Digits : constant := 6;
IEEEL_Digits : constant := 15;
! IEEEX_Digits : constant := 18;
VAXFF_Digits : constant := 6;
VAXDF_Digits : constant := 9;
VAXGF_Digits : constant := 15;
IEEES_Emax : constant := 84;
IEEEL_Emax : constant := 200;
! IEEEX_Emax : constant := 244;
VAXFF_Emax : constant := 84;
VAXDF_Emax : constant := 124;
VAXGF_Emax : constant := 204;
IEEES_Machine_Emax : constant := 128;
IEEEL_Machine_Emax : constant := 1024;
! IEEEX_Machine_Emax : constant := 16384;
VAXFF_Machine_Emax : constant := 127;
VAXDF_Machine_Emax : constant := 127;
VAXGF_Machine_Emax : constant := 1023;
IEEES_Machine_Emin : constant := -125;
IEEEL_Machine_Emin : constant := -1021;
! IEEEX_Machine_Emin : constant := -16381;
VAXFF_Machine_Emin : constant := -127;
VAXDF_Machine_Emin : constant := -127;
VAXGF_Machine_Emin : constant := -1023;
IEEES_Machine_Mantissa : constant := 24;
IEEEL_Machine_Mantissa : constant := 53;
! IEEEX_Machine_Mantissa : constant := 64;
VAXFF_Machine_Mantissa : constant := 24;
VAXDF_Machine_Mantissa : constant := 56;
VAXGF_Machine_Mantissa : constant := 53;
IEEES_Mantissa : constant := 21;
IEEEL_Mantissa : constant := 51;
! IEEEX_Mantissa : constant := 61;
VAXFF_Mantissa : constant := 24;
VAXDF_Mantissa : constant := 56;
VAXGF_Mantissa : constant := 53;
IEEES_Model_Emin : constant := -125;
IEEEL_Model_Emin : constant := -1021;
! IEEEX_Model_Emin : constant := -16381;
VAXFF_Model_Emin : constant := -127;
VAXDF_Model_Emin : constant := -127;
VAXGF_Model_Emin : constant := -1023;
IEEES_Model_Mantissa : constant := 24;
IEEEL_Model_Mantissa : constant := 53;
! IEEEX_Model_Mantissa : constant := 64;
VAXFF_Model_Mantissa : constant := 24;
VAXDF_Model_Mantissa : constant := 56;
VAXGF_Model_Mantissa : constant := 53;
IEEES_Safe_Emax : constant := 128;
IEEEL_Safe_Emax : constant := 1024;
! IEEEX_Safe_Emax : constant := 16384;
VAXFF_Safe_Emax : constant := 127;
VAXDF_Safe_Emax : constant := 127;
VAXGF_Safe_Emax : constant := 1023;
--- 50,112 ----
IEEES_Digits : constant := 6;
IEEEL_Digits : constant := 15;
! IEEEX_Digits : constant := 15;
VAXFF_Digits : constant := 6;
VAXDF_Digits : constant := 9;
VAXGF_Digits : constant := 15;
IEEES_Emax : constant := 84;
IEEEL_Emax : constant := 200;
! IEEEX_Emax : constant := 200;
VAXFF_Emax : constant := 84;
VAXDF_Emax : constant := 124;
VAXGF_Emax : constant := 204;
IEEES_Machine_Emax : constant := 128;
IEEEL_Machine_Emax : constant := 1024;
! IEEEX_Machine_Emax : constant := 1024;
VAXFF_Machine_Emax : constant := 127;
VAXDF_Machine_Emax : constant := 127;
VAXGF_Machine_Emax : constant := 1023;
IEEES_Machine_Emin : constant := -125;
IEEEL_Machine_Emin : constant := -1021;
! IEEEX_Machine_Emin : constant := -1021;
VAXFF_Machine_Emin : constant := -127;
VAXDF_Machine_Emin : constant := -127;
VAXGF_Machine_Emin : constant := -1023;
IEEES_Machine_Mantissa : constant := 24;
IEEEL_Machine_Mantissa : constant := 53;
! IEEEX_Machine_Mantissa : constant := 53;
VAXFF_Machine_Mantissa : constant := 24;
VAXDF_Machine_Mantissa : constant := 56;
VAXGF_Machine_Mantissa : constant := 53;
IEEES_Mantissa : constant := 21;
IEEEL_Mantissa : constant := 51;
! IEEEX_Mantissa : constant := 51;
VAXFF_Mantissa : constant := 24;
VAXDF_Mantissa : constant := 56;
VAXGF_Mantissa : constant := 53;
IEEES_Model_Emin : constant := -125;
IEEEL_Model_Emin : constant := -1021;
! IEEEX_Model_Emin : constant := -1021;
VAXFF_Model_Emin : constant := -127;
VAXDF_Model_Emin : constant := -127;
VAXGF_Model_Emin : constant := -1023;
IEEES_Model_Mantissa : constant := 24;
IEEEL_Model_Mantissa : constant := 53;
! IEEEX_Model_Mantissa : constant := 53;
VAXFF_Model_Mantissa : constant := 24;
VAXDF_Model_Mantissa : constant := 56;
VAXGF_Model_Mantissa : constant := 53;
IEEES_Safe_Emax : constant := 128;
IEEEL_Safe_Emax : constant := 1024;
! IEEEX_Safe_Emax : constant := 1024;
VAXFF_Safe_Emax : constant := 127;
VAXDF_Safe_Emax : constant := 127;
VAXGF_Safe_Emax : constant := 1023;
***************
*** 117,172 ****
IEEES_Epsilon : constant := 2#1.0#E-20;
IEEEL_Epsilon : constant := 2#1.0#E-49;
! IEEEX_Epsilon : constant := 2#1.0#E-60;
VAXFF_Epsilon : constant := 16#0.1000_000#E-4;
VAXDF_Epsilon : constant := 16#0.4000_0000_0000_000#E-7;
VAXGF_Epsilon : constant := 16#0.4000_0000_0000_00#E-12;
IEEES_Large : constant := 16#0.FFFF_F8#E+21;
IEEEL_Large : constant := 16#0.FFFF_FFFF_FFFF_C#E+50;
! IEEEX_Large : constant := 16#0.FFFF_FFFF_FFFF_FFF8#E+61;
VAXFF_Large : constant := 16#0.FFFF_F80#E+21;
VAXDF_Large : constant := 16#0.FFFF_FFFE_0000_000#E+31;
VAXGF_Large : constant := 16#0.FFFF_FFFF_FFFF_E0#E-51;
IEEES_Model_Epsilon : constant := 2#1.0#E-23;
IEEEL_Model_Epsilon : constant := 2#1.0#E-52;
! IEEEX_Model_Epsilon : constant := 2#1.0#E-63;
VAXFF_Model_Epsilon : constant := 16#0.1000_000#E-4;
VAXDF_Model_Epsilon : constant := 16#0.4000_0000_0000_000#E-7;
VAXGF_Model_Epsilon : constant := 16#0.4000_0000_0000_00#E-12;
IEEES_Model_Small : constant := 2#1.0#E-126;
IEEEL_Model_Small : constant := 2#1.0#E-1022;
! IEEEX_Model_Small : constant := 2#1.0#E-16381;
VAXFF_Model_Small : constant := 16#0.8000_000#E-21;
VAXDF_Model_Small : constant := 16#0.8000_0000_0000_000#E-31;
VAXGF_Model_Small : constant := 16#0.8000_0000_0000_00#E-51;
IEEES_Safe_First : constant := -16#0.FFFF_FF#E+32;
IEEEL_Safe_First : constant := -16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Safe_First : constant := -16#0.FFFF_FFFF_FFFF_FFFF#E+4096;
VAXFF_Safe_First : constant := -16#0.7FFF_FF8#E+32;
VAXDF_Safe_First : constant := -16#0.7FFF_FFFF_FFFF_FF8#E-38;
VAXGF_Safe_First : constant := -16#0.7FFF_FFFF_FFFF_FC#E-256;
IEEES_Safe_Large : constant := 16#0.FFFF_FF#E+32;
IEEEL_Safe_Large : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Safe_Large : constant := 16#0.FFFF_FFFF_FFFF_FFFF#E+4096;
VAXFF_Safe_Large : constant := 16#0.7FFF_FC0#E+32;
VAXDF_Safe_Large : constant := 16#0.7FFF_FFFF_0000_000#E+32;
VAXGF_Safe_Large : constant := 16#0.7FFF_FFFF_FFFF_F0#E+256;
IEEES_Safe_Last : constant := 16#0.FFFF_FF#E+32;
IEEEL_Safe_Last : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Safe_Last : constant := 16#0.FFFF_FFFF_FFFF_FFFF#E+4096;
VAXFF_Safe_Last : constant := 16#0.7FFF_FF8#E+32;
VAXDF_Safe_Last : constant := 16#0.7FFF_FFFF_FFFF_FC0#E+32;
VAXGF_Safe_Last : constant := 16#0.7FFF_FFFF_FFFF_FC#E+256;
IEEES_Safe_Small : constant := 2#1.0#E-126;
IEEEL_Safe_Small : constant := 2#1.0#E-1022;
! IEEEX_Safe_Small : constant := 2#1.0#E-16381;
VAXFF_Safe_Small : constant := 16#0.1000_000#E-31;
VAXDF_Safe_Small : constant := 16#0.1000_0000_0000_000#E-31;
VAXGF_Safe_Small : constant := 16#0.1000_0000_0000_00#E-255;
--- 117,172 ----
IEEES_Epsilon : constant := 2#1.0#E-20;
IEEEL_Epsilon : constant := 2#1.0#E-49;
! IEEEX_Epsilon : constant := 2#1.0#E-49;
VAXFF_Epsilon : constant := 16#0.1000_000#E-4;
VAXDF_Epsilon : constant := 16#0.4000_0000_0000_000#E-7;
VAXGF_Epsilon : constant := 16#0.4000_0000_0000_00#E-12;
IEEES_Large : constant := 16#0.FFFF_F8#E+21;
IEEEL_Large : constant := 16#0.FFFF_FFFF_FFFF_C#E+50;
! IEEEX_Large : constant := 16#0.FFFF_FFFF_FFFF_C#E+50;
VAXFF_Large : constant := 16#0.FFFF_F80#E+21;
VAXDF_Large : constant := 16#0.FFFF_FFFE_0000_000#E+31;
VAXGF_Large : constant := 16#0.FFFF_FFFF_FFFF_E0#E-51;
IEEES_Model_Epsilon : constant := 2#1.0#E-23;
IEEEL_Model_Epsilon : constant := 2#1.0#E-52;
! IEEEX_Model_Epsilon : constant := 2#1.0#E-52;
VAXFF_Model_Epsilon : constant := 16#0.1000_000#E-4;
VAXDF_Model_Epsilon : constant := 16#0.4000_0000_0000_000#E-7;
VAXGF_Model_Epsilon : constant := 16#0.4000_0000_0000_00#E-12;
IEEES_Model_Small : constant := 2#1.0#E-126;
IEEEL_Model_Small : constant := 2#1.0#E-1022;
! IEEEX_Model_Small : constant := 2#1.0#E-1022;
VAXFF_Model_Small : constant := 16#0.8000_000#E-21;
VAXDF_Model_Small : constant := 16#0.8000_0000_0000_000#E-31;
VAXGF_Model_Small : constant := 16#0.8000_0000_0000_00#E-51;
IEEES_Safe_First : constant := -16#0.FFFF_FF#E+32;
IEEEL_Safe_First : constant := -16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Safe_First : constant := -16#0.FFFF_FFFF_FFFF_F8#E+256;
VAXFF_Safe_First : constant := -16#0.7FFF_FF8#E+32;
VAXDF_Safe_First : constant := -16#0.7FFF_FFFF_FFFF_FF8#E-38;
VAXGF_Safe_First : constant := -16#0.7FFF_FFFF_FFFF_FC#E-256;
IEEES_Safe_Large : constant := 16#0.FFFF_FF#E+32;
IEEEL_Safe_Large : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Safe_Large : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
VAXFF_Safe_Large : constant := 16#0.7FFF_FC0#E+32;
VAXDF_Safe_Large : constant := 16#0.7FFF_FFFF_0000_000#E+32;
VAXGF_Safe_Large : constant := 16#0.7FFF_FFFF_FFFF_F0#E+256;
IEEES_Safe_Last : constant := 16#0.FFFF_FF#E+32;
IEEEL_Safe_Last : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Safe_Last : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
VAXFF_Safe_Last : constant := 16#0.7FFF_FF8#E+32;
VAXDF_Safe_Last : constant := 16#0.7FFF_FFFF_FFFF_FC0#E+32;
VAXGF_Safe_Last : constant := 16#0.7FFF_FFFF_FFFF_FC#E+256;
IEEES_Safe_Small : constant := 2#1.0#E-126;
IEEEL_Safe_Small : constant := 2#1.0#E-1022;
! IEEEX_Safe_Small : constant := 2#1.0#E-1022;
VAXFF_Safe_Small : constant := 16#0.1000_000#E-31;
VAXDF_Safe_Small : constant := 16#0.1000_0000_0000_000#E-31;
VAXGF_Safe_Small : constant := 16#0.1000_0000_0000_00#E-255;
***************
*** 182,195 ****
IEEES_First : constant := -16#0.FFFF_FF#E+32;
IEEEL_First : constant := -16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_First : constant := -16#0.FFFF_FFFF_FFFF_FFFF#E+4096;
VAXFF_First : constant := -16#0.7FFF_FF8#E+32;
VAXDF_First : constant := -16#0.7FFF_FFFF_FFFF_FF8#E+32;
VAXGF_First : constant := -16#0.7FFF_FFFF_FFFF_FC#E+256;
IEEES_Last : constant := 16#0.FFFF_FF#E+32;
IEEEL_Last : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Last : constant := 16#0.FFFF_FFFF_FFFF_FFFF#E+4096;
VAXFF_Last : constant := 16#0.7FFF_FF8#E+32;
VAXDF_Last : constant := 16#0.7FFF_FFFF_FFFF_FC0#E+32;
VAXGF_Last : constant := 16#0.7FFF_FFFF_FFFF_FC#E+256;
--- 182,195 ----
IEEES_First : constant := -16#0.FFFF_FF#E+32;
IEEEL_First : constant := -16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_First : constant := -16#0.FFFF_FFFF_FFFF_F8#E+256;
VAXFF_First : constant := -16#0.7FFF_FF8#E+32;
VAXDF_First : constant := -16#0.7FFF_FFFF_FFFF_FF8#E+32;
VAXGF_First : constant := -16#0.7FFF_FFFF_FFFF_FC#E+256;
IEEES_Last : constant := 16#0.FFFF_FF#E+32;
IEEEL_Last : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
! IEEEX_Last : constant := 16#0.FFFF_FFFF_FFFF_F8#E+256;
VAXFF_Last : constant := 16#0.7FFF_FF8#E+32;
VAXDF_Last : constant := 16#0.7FFF_FFFF_FFFF_FC0#E+32;
VAXGF_Last : constant := 16#0.7FFF_FFFF_FFFF_FC#E+256;
-------------- next part --------------
*** config/i386/t-i386bare Sat Feb 13 14:39:54 1999
--- config/i386/t-i386bare Tue Feb 16 21:03:20 1999
***************
*** 1,3 ****
--- 1,26 ----
# The i386 md has all of these taken care of, according to sef.
LIBGCC1 =
CROSS_LIBGCC1 =
+
+ LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c xp-bit.c
+
+ dp-bit.c: $(srcdir)/config/fp-bit.c
+ echo '#define FLOAT_BIT_ORDER_MISMATCH' > dp-bit.c
+ cat $(srcdir)/config/fp-bit.c >> dp-bit.c
+
+ fp-bit.c: $(srcdir)/config/fp-bit.c
+ echo '#define FLOAT' > fp-bit.c
+ echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
+ cat $(srcdir)/config/fp-bit.c >> fp-bit.c
+
+ xp-bit.c: $(srcdir)/config/fp-bit.c
+ echo '#define EXTENDED_FLOAT_STUBS' > xp-bit.c
+ cat $(srcdir)/config/fp-bit.c >> xp-bit.c
+
+ MULTILIB_OPTIONS=msoft-float mno-fp-ret-in-387
+ MULTILIB_DIRNAMES=soft-float no-fp-ret
+ MULTILIB_MATCHES=
+ MULTILIB_EXCEPTIONS=mno-fp-ret-in-387
+
+ LIBGCC = stmp-multilib
+ INSTALL_LIBGCC = install-multilib