Hello!

Attached patch enables soft-float multilibs for x86-32 RTEMS. The
patch activates SFmode and DFmode soft-float support routines. The
XFmode is mapped to DFmode due to lack of XFmode support in
soft-float. We already disable FPU return registers for -mno-80387, so
ABI is already changed for soft-float. The XFmode->DFmode mapping just
rides on this change.

gcc/

2013-11-05  Uros Bizjak  <ubiz...@gmail.com>

    * config/i386/i386-c.c (ix86_target_macros): Define _SOFT_FLOAT
    for !TARGET_80387.
    * config/i386/rtemself.h (TARGET_OS_CPP_BUILTINS): Do not define
    _SOFT_FLOAT here.
    (LONG_DOUBLE_TYPE_SIZE): New define.
    (LIBGCC2_LONG_DOUBLE_TYPE_SIZE): Ditto.

libgcc/

2013-11-05  Uros Bizjak  <ubiz...@gmail.com>

    * config/i386/32/sfp-machine.h (_FP_MUL_MEAT_S): Define.
    (_FP_MUL_MEAT_D): Ditto.
    (_FP_DIV_MEAT_S): Ditto.
    (_FP_DIV_MEAT_D): Ditto.
    * config.host (i[34567]86-*-rtems*): Remove i386/t-softfp, add
    t-softfp-sfdf and t-softfp to tmake_file.

Patch was tested by Ralf on RTEMS (currently, -march=pentiumpro
multilib ICEs during build due to PR 58853 [1]).

It should be relatively straightforward to implement x86-32 Android
soft-fp multilib following the above RTEMS example. Let's leave this
implementation to an interested reader ;)

Patch was committed to mainline SVN.

[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58853

Uros.
Index: gcc/config/i386/i386-c.c
===================================================================
--- gcc/config/i386/i386-c.c    (revision 204324)
+++ gcc/config/i386/i386-c.c    (working copy)
@@ -467,6 +467,9 @@
       builtin_define_std ("i386");
     }
 
+  if (!TARGET_80387)
+    cpp_define (parse_in, "_SOFT_FLOAT");
+
   if (TARGET_LONG_DOUBLE_64)
     cpp_define (parse_in, "__LONG_DOUBLE_64__");
 
Index: gcc/config/i386/rtemself.h
===================================================================
--- gcc/config/i386/rtemself.h  (revision 204324)
+++ gcc/config/i386/rtemself.h  (working copy)
@@ -26,7 +26,15 @@
        builtin_define ("__rtems__");           \
        builtin_define ("__USE_INIT_FINI__");   \
        builtin_assert ("system=rtems");        \
-       if (!TARGET_80387)                      \
-         builtin_define ("_SOFT_FLOAT");       \
     }                                          \
   while (0)
+
+#undef LONG_DOUBLE_TYPE_SIZE
+#define LONG_DOUBLE_TYPE_SIZE (TARGET_80387 ? 80 : 64)
+
+#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
+#ifdef _SOFT_FLOAT
+#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
+#else
+#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80
+#endif
Index: gcc/config/i386/t-rtems
===================================================================
--- gcc/config/i386/t-rtems     (revision 204324)
+++ gcc/config/i386/t-rtems     (working copy)
@@ -17,9 +17,9 @@
 # <http://www.gnu.org/licenses/>.
 #
 
-MULTILIB_OPTIONS = mtune=i486/mtune=pentium/mtune=pentiumpro \
+MULTILIB_OPTIONS = mtune=i486/mtune=pentium \
 msoft-float
-MULTILIB_DIRNAMES= m486 mpentium mpentiumpro soft-float
+MULTILIB_DIRNAMES= m486 mpentium soft-float
 MULTILIB_MATCHES = msoft-float=mno-m80387
 MULTILIB_MATCHES += mtune?pentium=mtune?k6 mtune?pentiumpro=mtune?mathlon
 MULTILIB_EXCEPTIONS = \
Index: libgcc/config/i386/32/sfp-machine.h
===================================================================
--- libgcc/config/i386/32/sfp-machine.h (revision 204324)
+++ libgcc/config/i386/32/sfp-machine.h (working copy)
@@ -65,9 +65,15 @@
             "g" ((USItype) (y0)))
 
 
+#define _FP_MUL_MEAT_S(R,X,Y)                          \
+  _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y)                          \
+  _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
 #define _FP_MUL_MEAT_Q(R,X,Y)                          \
   _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
 
+#define _FP_DIV_MEAT_S(R,X,Y)   _FP_DIV_MEAT_1_loop(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y)   _FP_DIV_MEAT_2_udiv(D,R,X,Y)
 #define _FP_DIV_MEAT_Q(R,X,Y)   _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
 
 #define _FP_NANFRAC_S          _FP_QNANBIT_S
Index: libgcc/config.host
===================================================================
--- libgcc/config.host  (revision 204324)
+++ libgcc/config.host  (working copy)
@@ -564,7 +564,7 @@
        extra_parts=crtbegin.o
        ;;
 i[34567]86-*-rtems*)
-       tmake_file="$tmake_file i386/t-softfp i386/t-crtstuff"
+       tmake_file="$tmake_file i386/t-crtstuff t-softfp-sfdf t-softfp"
        extra_parts="$extra_parts crti.o crtn.o"
        ;;
 i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)

Reply via email to