This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] PowerPC 128 bit long double compatibility (PR target/19019)


	The GCC and IBM XLC semantics of the 128-bit long double differ
and do not interoperate completely.  This patch renames the support
functions to unique names so that the compilers do not try to use each
other's support functions.

	This will need to be pushed back into GCC 3.4 and Linux distros
using GCC 3.4 as well.

David

	* config/rs6000/darwin-ldouble.c (_xlqadd): Rename to __gcc_qadd.
	(_xlqsub): Rename to __gcc_qsub.
	(_xlqmul): Rename to __gcc_qmul.
	(_xlqdiv): Rename to __gcc_qdiv.
	* config/rs6000/libgcc-ppc64.ver: Rename symbols.
	* config/rs6000/rs6000.c (rs6000_init_libfuncs): Rename symbols.
	* config/rs6000/t-aix43 (LIB2FUNCS_EXTRA): New.
	* config/rs6000/t-aix52 (LIB2FUNCS_EXTRA): New.
	* config/rs6000/t-newas (LIB2FUNCS_EXTRA): New.

Index: darwin-ldouble.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/darwin-ldouble.c,v
retrieving revision 1.8
diff -c -p -r1.8 darwin-ldouble.c
*** darwin-ldouble.c	31 Jul 2004 01:40:16 -0000	1.8
--- darwin-ldouble.c	14 Feb 2005 22:08:49 -0000
*************** Software Foundation, 59 Temple Place - S
*** 30,41 ****
  /* Implementations of floating-point long double basic arithmetic
     functions called by the IBM C compiler when generating code for
     PowerPC platforms.  In particular, the following functions are
!    implemented: _xlqadd, _xlqsub, _xlqmul, and _xlqdiv.  Double-double
!    algorithms are based on the paper "Doubled-Precision IEEE Standard
!    754 Floating-Point Arithmetic" by W. Kahan, February 26, 1987.  An
!    alternative published reference is "Software for Doubled-Precision
!    Floating-Point Computations", by Seppo Linnainmaa, ACM TOMS vol 7
!    no 3, September 1981, pages 272-283.  */
  
  /* Each long double is made up of two IEEE doubles.  The value of the
     long double is the sum of the values of the two parts.  The most
--- 30,41 ----
  /* Implementations of floating-point long double basic arithmetic
     functions called by the IBM C compiler when generating code for
     PowerPC platforms.  In particular, the following functions are
!    implemented: __gcc_qadd, __gcc_qsub, __gcc_qmul, and __gcc_qdiv.
!    Double-double algorithms are based on the paper "Doubled-Precision
!    IEEE Standard 754 Floating-Point Arithmetic" by W. Kahan, February 26,
!    1987.  An alternative published reference is "Software for
!    Doubled-Precision Floating-Point Computations", by Seppo Linnainmaa,
!    ACM TOMS vol 7 no 3, September 1981, pages 272-283.  */
  
  /* Each long double is made up of two IEEE doubles.  The value of the
     long double is the sum of the values of the two parts.  The most
*************** Software Foundation, 59 Temple Place - S
*** 48,54 ****
  
     This code currently assumes big-endian.  */
  
! #if !_SOFT_FLOAT && (defined (__MACH__) || defined (__powerpc64__))
  
  #define fabs(x) __builtin_fabs(x)
  #define isless(x, y) __builtin_isless (x, y)
--- 48,54 ----
  
     This code currently assumes big-endian.  */
  
! #if !_SOFT_FLOAT && (defined (__MACH__) || defined (__powerpc64__) || defined (_AIX))
  
  #define fabs(x) __builtin_fabs(x)
  #define isless(x, y) __builtin_isless (x, y)
*************** Software Foundation, 59 Temple Place - S
*** 62,71 ****
     but GCC currently generates poor code when a union is used to turn
     a long double into a pair of doubles.  */
  
! extern long double _xlqadd (double, double, double, double);
! extern long double _xlqsub (double, double, double, double);
! extern long double _xlqmul (double, double, double, double);
! extern long double _xlqdiv (double, double, double, double);
  
  typedef union
  {
--- 62,71 ----
     but GCC currently generates poor code when a union is used to turn
     a long double into a pair of doubles.  */
  
! extern long double __gcc_qadd (double, double, double, double);
! extern long double __gcc_qsub (double, double, double, double);
! extern long double __gcc_qmul (double, double, double, double);
! extern long double __gcc_qdiv (double, double, double, double);
  
  typedef union
  {
*************** typedef union
*** 75,81 ****
  
  /* Add two 'long double' values and return the result.	*/
  long double
! _xlqadd (double a, double aa, double c, double cc)
  {
    longDblUnion x;
    double z, q, zz, xh;
--- 75,81 ----
  
  /* Add two 'long double' values and return the result.	*/
  long double
! __gcc_qadd (double a, double aa, double c, double cc)
  {
    longDblUnion x;
    double z, q, zz, xh;
*************** _xlqadd (double a, double aa, double c, 
*** 110,122 ****
  }
  
  long double
! _xlqsub (double a, double b, double c, double d)
  {
!   return _xlqadd (a, b, -c, -d);
  }
  
  long double
! _xlqmul (double a, double b, double c, double d)
  {
    longDblUnion z;
    double t, tau, u, v, w;
--- 110,122 ----
  }
  
  long double
! __gcc_qsub (double a, double b, double c, double d)
  {
!   return __gcc_qadd (a, b, -c, -d);
  }
  
  long double
! __gcc_qmul (double a, double b, double c, double d)
  {
    longDblUnion z;
    double t, tau, u, v, w;
*************** _xlqmul (double a, double b, double c, d
*** 145,151 ****
  }
  
  long double
! _xlqdiv (double a, double b, double c, double d)
  {
    longDblUnion z;
    double s, sigma, t, tau, u, v, w;
--- 145,151 ----
  }
  
  long double
! __gcc_qdiv (double a, double b, double c, double d)
  {
    longDblUnion z;
    double s, sigma, t, tau, u, v, w;
Index: libgcc-ppc64.ver
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/libgcc-ppc64.ver,v
retrieving revision 1.2
diff -c -p -r1.2 libgcc-ppc64.ver
*** libgcc-ppc64.ver	7 Feb 2004 03:06:46 -0000	1.2
--- libgcc-ppc64.ver	14 Feb 2005 22:08:49 -0000
***************
*** 1,7 ****
  GCC_3.4 {
    # long double support
!   _xlqadd
!   _xlqsub
!   _xlqmul
!   _xlqdiv
  }
--- 1,7 ----
  GCC_3.4 {
    # long double support
!   __gcc_qadd
!   __gcc_qsub
!   __gcc_qmul
!   __gcc_qdiv
  }
Index: rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.785
diff -c -p -r1.785 rs6000.c
*** rs6000.c	13 Feb 2005 21:31:25 -0000	1.785
--- rs6000.c	14 Feb 2005 22:08:49 -0000
*************** rs6000_init_libfuncs (void)
*** 8871,8880 ****
  	}
  
        /* Standard AIX/Darwin/64-bit SVR4 quad floating point routines.  */
!       set_optab_libfunc (add_optab, TFmode, "_xlqadd");
!       set_optab_libfunc (sub_optab, TFmode, "_xlqsub");
!       set_optab_libfunc (smul_optab, TFmode, "_xlqmul");
!       set_optab_libfunc (sdiv_optab, TFmode, "_xlqdiv");
      }
    else
      {
--- 8871,8880 ----
  	}
  
        /* Standard AIX/Darwin/64-bit SVR4 quad floating point routines.  */
!       set_optab_libfunc (add_optab, TFmode, "__gcc_qadd");
!       set_optab_libfunc (sub_optab, TFmode, "__gcc_qsub");
!       set_optab_libfunc (smul_optab, TFmode, "__gcc_qmul");
!       set_optab_libfunc (sdiv_optab, TFmode, "__gcc_qdiv");
      }
    else
      {
Index: t-aix43
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/t-aix43,v
retrieving revision 1.22
diff -c -p -r1.22 t-aix43
*** t-aix43	10 Jan 2005 15:10:05 -0000	1.22
--- t-aix43	14 Feb 2005 22:08:49 -0000
*************** SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
*** 61,66 ****
--- 61,69 ----
  SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver
  SHLIB_NM_FLAGS = -Bpg -X32_64
  
+ # GCC 128-bit long double support routines.
+ LIB2FUNCS_EXTRA = $(srcdir)/config/rs6000/darwin-ldouble.c
+ 
  # Either 32-bit and 64-bit objects in archives.
  AR_FLAGS_FOR_TARGET = -X32_64
  
Index: t-aix52
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/t-aix52,v
retrieving revision 1.5
diff -c -p -r1.5 t-aix52
*** t-aix52	7 Dec 2004 18:44:31 -0000	1.5
--- t-aix52	14 Feb 2005 22:08:49 -0000
*************** SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
*** 42,47 ****
--- 42,50 ----
  SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver
  SHLIB_NM_FLAGS = -Bpg -X32_64
  
+ # GCC 128-bit long double support routines.
+ LIB2FUNCS_EXTRA = $(srcdir)/config/rs6000/darwin-ldouble.c
+ 
  # Either 32-bit and 64-bit objects in archives.
  AR_FLAGS_FOR_TARGET = -X32_64
  
Index: t-newas
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/t-newas,v
retrieving revision 1.6
diff -c -p -r1.6 t-newas
*** t-newas	18 Dec 2002 22:45:35 -0000	1.6
--- t-newas	14 Feb 2005 22:08:49 -0000
*************** MULTILIB_MATCHES	= $(MULTILIB_MATCHES_FL
*** 27,32 ****
--- 27,35 ----
  			  mcpu?powerpc=mpowerpc-gpopt \
  			  mcpu?powerpc=mpowerpc-gfxopt
  
+ # GCC 128-bit long double support routines.
+ LIB2FUNCS_EXTRA = $(srcdir)/config/rs6000/darwin-ldouble.c
+ 
  # Aix 3.2.x needs milli.exp for -mcpu=common
  EXTRA_PARTS = milli.exp
  milli.exp: $(srcdir)/config/rs6000/milli.exp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]