Patch for PR target/19930 [pow(long double, int) on ia64]
Steve Ellcey
sje@cup.hp.com
Thu Feb 24 23:32:00 GMT 2005
I was looking at PR 19930 and after wondering about the pluses and
minuses of trying to use the HP pow function that is in libm I began to
wonder why libgcc2 couldn't contain both XFmode and TFmode routines.
Not finding a good answer, I came up with the following patch that fixes
PR 19930 by allowing libgcc2 to contain both types of routines (if
desired) so that a platform could support both types of floating point
formats. The default behavour of what gets included in libgcc does not
change.
I could not find any documentation for LIBGCC2_LONG_DOUBLE_TYPE_SIZE so
I added that as well as documentation for my two new macros.
The IA64 specific part of the patch is needed to build a libgcc with
both types of routines and to fix a problem with duplicate entry points.
After the change the HP-UX libgcc contains three new entry points that
were not there before: __powitf2, __divtc3, and __multc3.
This patch was built and tested on IA64 HP-UX and Linux with no
regressions and it fixes gcc.dg/pr19402-2.c on HP-UX.
Ok for checkin?
Steve Ellcey
sje@cup.hp.com
2005-02-24 Steve Ellcey <sje@cup.hp.com>
PR target/19930
* doc/tm.texi (LIBGCC2_LONG_DOUBLE_TYPE_SIZE): Document.
(LIBGCC2_NEED_XF_MODE): New.
(LIBGCC2_NEED_TF_MODE): New.
* libgcc2.h (LIBGCC2_NEED_XF_MODE): Define default.
(LIBGCC2_NEED_TF_MODE): Define default.
* libgcc2.c (LIBGCC2_NEED_XF_MODE): New.
(LIBGCC2_NEED_TF_MODE): New.
* config/ia64/t-ia64 (LIB1ASMFUNCS): Remove __compat
and add _fixtfdi, _fixunstfdi, _floatditf
* lib1funcs.asm: Remove L__compat. Add L_fixtfdi,
L_fixunstfdi, L_floatditf.
* config/ia64/hpux.h (LIBGCC2_NEED_XF_MODE): Define.
(LIBGCC2_NEED_TF_MODE): Define.
*** gcc.orig/gcc/doc/tm.texi Thu Feb 24 09:54:47 2005
--- gcc/gcc/doc/tm.texi Thu Feb 24 09:54:39 2005
*************** the target machine. If you don't define
*** 1646,1651 ****
--- 1646,1672 ----
words.
@end defmac
+ @defmac LIBGCC2_LONG_DOUBLE_TYPE_SIZE
+ Define this macro if @code{LONG_DOUBLE_TYPE_SIZE} is not constant or
+ if you want routines in @file{libgcc2.a} for a size other than
+ @code{LONG_DOUBLE_TYPE_SIZE}. If you don't define this, the
+ default is @code{LONG_DOUBLE_TYPE_SIZE}.
+ @end defmac
+
+ @defmac LIBGCC2_NEED_XF_MODE
+ Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
+ @code{XFmode} but you want @code{XFmode} routines in @file{libgcc2.a}
+ anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
+ is 80 then the default is 1, otherwise it is 0.
+ @end defmac
+
+ @defmac LIBGCC2_NEED_TF_MODE
+ Define this macro if @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE} is not
+ @code{TFmode} but you want @code{TFmode} routines in @file{libgcc2.a}
+ anyway. If you don't define this and @code{LIBGCC2_LONG_DOUBLE_TYPE_SIZE}
+ is 128 then the default is 1, otherwise it is 0.
+ @end defmac
+
@defmac TARGET_FLT_EVAL_METHOD
A C expression for the value for @code{FLT_EVAL_METHOD} in @file{float.h},
assuming, if applicable, that the floating-point control word is in its
*** gcc.orig/gcc/libgcc2.h Thu Feb 24 09:07:39 2005
--- gcc/gcc/libgcc2.h Thu Feb 24 09:07:28 2005
*************** extern short int __get_eh_table_version
*** 55,60 ****
--- 55,68 ----
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE
#endif
+ #ifndef LIBGCC2_NEED_XF_MODE
+ #define LIBGCC2_NEED_XF_MODE (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
+ #endif
+
+ #ifndef LIBGCC2_NEED_TF_MODE
+ #define LIBGCC2_NEED_TF_MODE (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
+ #endif
+
#ifndef MIN_UNITS_PER_WORD
#define MIN_UNITS_PER_WORD UNITS_PER_WORD
#endif
*************** typedef float DFtype __attribute__ ((mo
*** 95,105 ****
typedef _Complex float SCtype __attribute__ ((mode (SC)));
typedef _Complex float DCtype __attribute__ ((mode (DC)));
! #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
typedef float XFtype __attribute__ ((mode (XF)));
typedef _Complex float XCtype __attribute__ ((mode (XC)));
#endif
! #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
typedef float TFtype __attribute__ ((mode (TF)));
typedef _Complex float TCtype __attribute__ ((mode (TC)));
#endif
--- 103,113 ----
typedef _Complex float SCtype __attribute__ ((mode (SC)));
typedef _Complex float DCtype __attribute__ ((mode (DC)));
! #if LIBGCC2_NEED_XF_MODE
typedef float XFtype __attribute__ ((mode (XF)));
typedef _Complex float XCtype __attribute__ ((mode (XC)));
#endif
! #if LIBGCC2_NEED_TF_MODE
typedef float TFtype __attribute__ ((mode (TF)));
typedef _Complex float TCtype __attribute__ ((mode (TC)));
#endif
*************** extern SCtype __mulsc3 (SFtype, SFtype,
*** 317,323 ****
extern DCtype __divdc3 (DFtype, DFtype, DFtype, DFtype);
extern DCtype __muldc3 (DFtype, DFtype, DFtype, DFtype);
! #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
extern DWtype __fixxfdi (XFtype);
extern DWtype __fixunsxfDI (XFtype);
extern XFtype __floatdixf (DWtype);
--- 325,331 ----
extern DCtype __divdc3 (DFtype, DFtype, DFtype, DFtype);
extern DCtype __muldc3 (DFtype, DFtype, DFtype, DFtype);
! #if LIBGCC2_NEED_XF_MODE
extern DWtype __fixxfdi (XFtype);
extern DWtype __fixunsxfDI (XFtype);
extern XFtype __floatdixf (DWtype);
*************** extern XCtype __divxc3 (XFtype, XFtype,
*** 327,333 ****
extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype);
#endif
! #if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
extern DWtype __fixunstfDI (TFtype);
extern DWtype __fixtfdi (TFtype);
extern TFtype __floatditf (DWtype);
--- 335,341 ----
extern XCtype __mulxc3 (XFtype, XFtype, XFtype, XFtype);
#endif
! #if LIBGCC2_NEED_TF_MODE
extern DWtype __fixunstfDI (TFtype);
extern DWtype __fixtfdi (TFtype);
extern TFtype __floatditf (DWtype);
*** gcc.orig/gcc/libgcc2.c Thu Feb 24 09:07:46 2005
--- gcc/gcc/libgcc2.c Thu Feb 24 09:06:46 2005
*************** __ucmpdi2 (DWtype a, DWtype b)
*** 1157,1163 ****
}
#endif
! #if defined(L_fixunstfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
--- 1157,1163 ----
}
#endif
! #if defined(L_fixunstfdi) && LIBGCC2_NEED_TF_MODE
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
*************** __fixunstfDI (TFtype a)
*** 1186,1192 ****
}
#endif
! #if defined(L_fixtfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
DWtype
__fixtfdi (TFtype a)
{
--- 1186,1192 ----
}
#endif
! #if defined(L_fixtfdi) && LIBGCC2_NEED_TF_MODE
DWtype
__fixtfdi (TFtype a)
{
*************** __fixtfdi (TFtype a)
*** 1196,1202 ****
}
#endif
! #if defined(L_fixunsxfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
--- 1196,1202 ----
}
#endif
! #if defined(L_fixunsxfdi) && LIBGCC2_NEED_XF_MODE
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
*************** __fixunsxfDI (XFtype a)
*** 1225,1231 ****
}
#endif
! #if defined(L_fixxfdi) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
DWtype
__fixxfdi (XFtype a)
{
--- 1225,1231 ----
}
#endif
! #if defined(L_fixxfdi) && LIBGCC2_NEED_XF_MODE
DWtype
__fixxfdi (XFtype a)
{
*************** __fixsfdi (SFtype a)
*** 1304,1310 ****
}
#endif
! #if defined(L_floatdixf) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80)
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
--- 1304,1310 ----
}
#endif
! #if defined(L_floatdixf) && LIBGCC2_NEED_XF_MODE
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
*************** __floatdixf (DWtype u)
*** 1321,1327 ****
}
#endif
! #if defined(L_floatditf) && (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
--- 1321,1327 ----
}
#endif
! #if defined(L_floatditf) && LIBGCC2_NEED_TF_MODE
#define WORD_SIZE (sizeof (Wtype) * BITS_PER_UNIT)
#define HIGH_HALFWORD_COEFF (((UDWtype) 1) << (WORD_SIZE / 2))
#define HIGH_WORD_COEFF (((UDWtype) 1) << WORD_SIZE)
*************** __floatdisf (DWtype u)
*** 1399,1405 ****
}
#endif
! #if defined(L_fixunsxfsi) && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80
/* Reenable the normal types, in case limits.h needs them. */
#undef char
#undef short
--- 1399,1405 ----
}
#endif
! #if defined(L_fixunsxfsi) && LIBGCC2_NEED_XF_MODE
/* Reenable the normal types, in case limits.h needs them. */
#undef char
#undef short
*************** __fixunssfSI (SFtype a)
*** 1469,1476 ****
exponents. */
#if defined(L_powisf2) || defined(L_powidf2) \
! || (defined(L_powixf2) && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80) \
! || (defined(L_powitf2) && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128)
# if defined(L_powisf2)
# define TYPE SFtype
# define NAME __powisf2
--- 1469,1476 ----
exponents. */
#if defined(L_powisf2) || defined(L_powidf2) \
! || (defined(L_powixf2) && LIBGCC2_NEED_XF_MODE) \
! || (defined(L_powitf2) && LIBGCC2_NEED_TF_MODE)
# if defined(L_powisf2)
# define TYPE SFtype
# define NAME __powisf2
*************** NAME (TYPE x, Wtype m)
*** 1503,1511 ****
#if defined(L_mulsc3) || defined(L_divsc3) \
|| defined(L_muldc3) || defined(L_divdc3) \
! || (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80 \
&& (defined(L_mulxc3) || defined(L_divxc3))) \
! || (LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128 \
&& (defined(L_multc3) || defined(L_divtc3)))
#undef float
--- 1503,1511 ----
#if defined(L_mulsc3) || defined(L_divsc3) \
|| defined(L_muldc3) || defined(L_divdc3) \
! || (LIBGCC2_NEED_XF_MODE \
&& (defined(L_mulxc3) || defined(L_divxc3))) \
! || (LIBGCC2_NEED_TF_MODE \
&& (defined(L_multc3) || defined(L_divtc3)))
#undef float
*** gcc.orig/gcc/config/ia64/t-ia64 Thu Feb 24 09:32:05 2005
--- gcc/gcc/config/ia64/t-ia64 Thu Feb 24 09:31:56 2005
*************** LIB1ASMSRC = ia64/lib1funcs.asm
*** 8,14 ****
LIB1ASMFUNCS = __divxf3 __divdf3 __divsf3 \
__divdi3 __moddi3 __udivdi3 __umoddi3 \
__divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \
! __nonlocal_goto __restore_stack_nonlocal __trampoline __compat
# ??? Hack to get -P option used when compiling lib1funcs.asm, because Intel
# assembler does not accept # line number as a comment.
--- 8,15 ----
LIB1ASMFUNCS = __divxf3 __divdf3 __divsf3 \
__divdi3 __moddi3 __udivdi3 __umoddi3 \
__divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \
! __nonlocal_goto __restore_stack_nonlocal __trampoline \
! _fixtfdi _fixunstfdi _floatditf
# ??? Hack to get -P option used when compiling lib1funcs.asm, because Intel
# assembler does not accept # line number as a comment.
*** gcc.orig/gcc/config/ia64/lib1funcs.asm Thu Feb 24 09:10:43 2005
--- gcc/gcc/config/ia64/lib1funcs.asm Thu Feb 24 09:10:52 2005
*************** __ia64_trampoline:
*** 706,714 ****
.endp __ia64_trampoline
#endif
- #ifdef L__compat
// Thunks for backward compatibility.
!
.text
.align 16
.global __fixtfti
--- 706,713 ----
.endp __ia64_trampoline
#endif
// Thunks for backward compatibility.
! #ifdef L_fixtfdi
.text
.align 16
.global __fixtfti
*************** __fixtfti:
*** 719,725 ****
;;
}
.endp __fixtfti
!
.align 16
.global __fixunstfti
.proc __fixunstfti
--- 718,725 ----
;;
}
.endp __fixtfti
! #endif
! #ifdef L_fixunstfdi
.align 16
.global __fixunstfti
.proc __fixunstfti
*************** __fixunstfti:
*** 729,735 ****
;;
}
.endp __fixunstfti
!
.align 16
.global __floattitf
.proc __floattitf
--- 729,736 ----
;;
}
.endp __fixunstfti
! #endif
! #if L_floatditf
.align 16
.global __floattitf
.proc __floattitf
*************** __floattitf:
*** 739,743 ****
;;
}
.endp __floattitf
-
#endif
--- 740,743 ----
*** gcc.orig/gcc/config/ia64/hpux.h Thu Feb 24 09:09:42 2005
--- gcc/gcc/config/ia64/hpux.h Thu Feb 24 09:09:34 2005
*************** do { \
*** 209,211 ****
--- 209,219 ----
#define TARGET_INIT_LIBFUNCS ia64_hpux_init_libfuncs
#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
+
+ /* Put all *xf routines in libgcc, regardless of long double size. */
+ #undef LIBGCC2_NEED_XF_MODE
+ #define LIBGCC2_NEED_XF_MODE 1
+
+ /* Put all *tf routines in libgcc, regardless of long double size. */
+ #undef LIBGCC2_NEED_TF_MODE
+ #define LIBGCC2_NEED_TF_MODE 1
More information about the Gcc-patches
mailing list