diff mbox

Remove LIBGCC2_TF_CEXT target macro

Message ID Pine.LNX.4.64.1409162140060.4182@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph Myers Sept. 16, 2014, 9:41 p.m. UTC
This patch removes the (undocumented) LIBGCC2_TF_CEXT target macro,
replacing it by -fbuilding-libgcc predefines (and thereby gets rid of
another LIBGCC2_LONG_DOUBLE_TYPE_SIZE conditional, though some more
patches are needed before that target macro can be eliminated).  This
macro indicated the suffix used on __builtin_huge_val,
__builtin_copysign, __builtin_fabs built-in function names to produce
the names for a given floating-point mode.

Predefines are added for all floating-point modes supported for
libgcc, not just TFmode.  These are fully accurate for modes
corresponding to float, double and long double.  For other modes, the
suffix for *constants* is determined by the targetm.c.mode_for_suffix
hook (the limit to two possible suffixes 'w' and 'q' being hardcoded
in various places).  This is in fact the suffix for built-in functions
as well where such functions exist.

* For i386, the *q functions always exist (whether or not TFmode is
  used for long double).  The *w functions never exist (but this
  doesn't matter for libgcc, since no i386 configuration treats XFmode
  as a supported scalar mode if long double is TFmode; if __float80
  were to be supported for 64-bit Android, properly such functions
  ought to be added).

* For ia64, the *q functions exist for non-HP-UX (under HP-UX, long
  double is TFmode, so they aren't needed).  The *w functions never
  exist.  This is an issue for this libgcc code for the XFmode complex
  functions in libgcc on HP-UX; as I understand it, right now those
  will accidentally be using TFmode versions of those three functions,
  so involving unnecessary conversions, while the sanity check on CEXT
  accidentally passes because all it tests is the sizes of the types.

Because of the lack of 'w' functions, the patch uses 'l' when the
constant suffix is 'w', matching what the existing libgcc code would
do for IA64 HP-UX in that case.

Ideally there would be generic code to create such built-in functions
for all supported floating-point types.  That may be something to
consider if support for TS 18661-3 (standard bindings for IEEE
754-2008, defining names such as _Float128, and function names such as
copysignf128) is added in future.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
commit?

gcc:
2014-09-16  Joseph Myers  <joseph@codesourcery.com>

	* system.h (LIBGCC2_TF_CEXT): Poison.
	* config/i386/cygming.h (LIBGCC2_TF_CEXT): Remove.
	* config/i386/darwin.h (LIBGCC2_TF_CEXT): Likewise.
	* config/i386/dragonfly.h (LIBGCC2_TF_CEXT): Likewise.
	* config/i386/freebsd.h (LIBGCC2_TF_CEXT): Likewise.
	* config/i386/gnu-user-common.h (LIBGCC2_TF_CEXT): Likewise.
	* config/i386/openbsdelf.h (LIBGCC2_TF_CEXT): Likewise.
	* config/i386/sol2.h (LIBGCC2_TF_CEXT): Likewise.
	* config/ia64/ia64.h (LIBGCC2_TF_CEXT): Likewise.
	* config/ia64/linux.h (LIBGCC2_TF_CEXT): Likewise.

gcc/c-family:
2014-09-16  Joseph Myers  <joseph@codesourcery.com>

	* c-cppbuiltin.c (c_cpp_builtins): Define __LIBGCC_*_FUNC_EXT__
	for supported floating-point modes.

libgcc:
2014-09-16  Joseph Myers  <joseph@codesourcery.com>

	* libgcc2.c (CEXT): Define using __LIBGCC_*_FUNC_EXT__.

Comments

Jeff Law Sept. 18, 2014, 11:23 p.m. UTC | #1
On 09/16/14 15:41, Joseph S. Myers wrote:
> This patch removes the (undocumented) LIBGCC2_TF_CEXT target macro,
> replacing it by -fbuilding-libgcc predefines (and thereby gets rid of
> another LIBGCC2_LONG_DOUBLE_TYPE_SIZE conditional, though some more
> patches are needed before that target macro can be eliminated).  This
> macro indicated the suffix used on __builtin_huge_val,
> __builtin_copysign, __builtin_fabs built-in function names to produce
> the names for a given floating-point mode.
>
> Predefines are added for all floating-point modes supported for
> libgcc, not just TFmode.  These are fully accurate for modes
> corresponding to float, double and long double.  For other modes, the
> suffix for *constants* is determined by the targetm.c.mode_for_suffix
> hook (the limit to two possible suffixes 'w' and 'q' being hardcoded
> in various places).  This is in fact the suffix for built-in functions
> as well where such functions exist.
>
> * For i386, the *q functions always exist (whether or not TFmode is
>    used for long double).  The *w functions never exist (but this
>    doesn't matter for libgcc, since no i386 configuration treats XFmode
>    as a supported scalar mode if long double is TFmode; if __float80
>    were to be supported for 64-bit Android, properly such functions
>    ought to be added).
>
> * For ia64, the *q functions exist for non-HP-UX (under HP-UX, long
>    double is TFmode, so they aren't needed).  The *w functions never
>    exist.  This is an issue for this libgcc code for the XFmode complex
>    functions in libgcc on HP-UX; as I understand it, right now those
>    will accidentally be using TFmode versions of those three functions,
>    so involving unnecessary conversions, while the sanity check on CEXT
>    accidentally passes because all it tests is the sizes of the types.
>
> Because of the lack of 'w' functions, the patch uses 'l' when the
> constant suffix is 'w', matching what the existing libgcc code would
> do for IA64 HP-UX in that case.
>
> Ideally there would be generic code to create such built-in functions
> for all supported floating-point types.  That may be something to
> consider if support for TS 18661-3 (standard bindings for IEEE
> 754-2008, defining names such as _Float128, and function names such as
> copysignf128) is added in future.
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
> commit?
>
> gcc:
> 2014-09-16  Joseph Myers  <joseph@codesourcery.com>
>
> 	* system.h (LIBGCC2_TF_CEXT): Poison.
> 	* config/i386/cygming.h (LIBGCC2_TF_CEXT): Remove.
> 	* config/i386/darwin.h (LIBGCC2_TF_CEXT): Likewise.
> 	* config/i386/dragonfly.h (LIBGCC2_TF_CEXT): Likewise.
> 	* config/i386/freebsd.h (LIBGCC2_TF_CEXT): Likewise.
> 	* config/i386/gnu-user-common.h (LIBGCC2_TF_CEXT): Likewise.
> 	* config/i386/openbsdelf.h (LIBGCC2_TF_CEXT): Likewise.
> 	* config/i386/sol2.h (LIBGCC2_TF_CEXT): Likewise.
> 	* config/ia64/ia64.h (LIBGCC2_TF_CEXT): Likewise.
> 	* config/ia64/linux.h (LIBGCC2_TF_CEXT): Likewise.
>
> gcc/c-family:
> 2014-09-16  Joseph Myers  <joseph@codesourcery.com>
>
> 	* c-cppbuiltin.c (c_cpp_builtins): Define __LIBGCC_*_FUNC_EXT__
> 	for supported floating-point modes.
>
> libgcc:
> 2014-09-16  Joseph Myers  <joseph@codesourcery.com>
>
> 	* libgcc2.c (CEXT): Define using __LIBGCC_*_FUNC_EXT__.
OK.
Jeff
diff mbox

Patch

Index: gcc/c-family/c-cppbuiltin.c
===================================================================
--- gcc/c-family/c-cppbuiltin.c	(revision 215300)
+++ gcc/c-family/c-cppbuiltin.c	(working copy)
@@ -956,6 +956,28 @@  c_cpp_builtins (cpp_reader *pfile)
 					+ sizeof ("__LIBGCC_HAS__MODE__"));
 	  sprintf (macro_name, "__LIBGCC_HAS_%s_MODE__", name);
 	  cpp_define (pfile, macro_name);
+	  macro_name = (char *) alloca (strlen (name)
+					+ sizeof ("__LIBGCC__FUNC_EXT__"));
+	  sprintf (macro_name, "__LIBGCC_%s_FUNC_EXT__", name);
+	  const char *suffix;
+	  if (mode == TYPE_MODE (double_type_node))
+	    suffix = "";
+	  else if (mode == TYPE_MODE (float_type_node))
+	    suffix = "f";
+	  else if (mode == TYPE_MODE (long_double_type_node))
+	    suffix = "l";
+	  /* ??? The following assumes the built-in functions (defined
+	     in target-specific code) match the suffixes used for
+	     constants.  Because in fact such functions are not
+	     defined for the 'w' suffix, 'l' is used there
+	     instead.  */
+	  else if (mode == targetm.c.mode_for_suffix ('q'))
+	    suffix = "q";
+	  else if (mode == targetm.c.mode_for_suffix ('w'))
+	    suffix = "l";
+	  else
+	    gcc_unreachable ();
+	  builtin_define_with_value (macro_name, suffix, 0);
 	}
 
       /* For libgcc crtstuff.c and libgcc2.c.  */
Index: gcc/config/i386/cygming.h
===================================================================
--- gcc/config/i386/cygming.h	(revision 215300)
+++ gcc/config/i386/cygming.h	(working copy)
@@ -339,9 +339,6 @@  do {						\
 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
 
-/* Put all *tf routines in libgcc.  */
-#define LIBGCC2_TF_CEXT q
-
 /* Output function declarations at the end of the file.  */
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END i386_pe_file_end
Index: gcc/config/i386/darwin.h
===================================================================
--- gcc/config/i386/darwin.h	(revision 215300)
+++ gcc/config/i386/darwin.h	(working copy)
@@ -153,9 +153,6 @@  extern int darwin_emit_branch_islands;
 
 #define SHIFT_DOUBLE_OMITS_COUNT 0
 
-/* Put all *tf routines in libgcc.  */
-#define LIBGCC2_TF_CEXT q
-
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END darwin_file_end
 
Index: gcc/config/i386/dragonfly.h
===================================================================
--- gcc/config/i386/dragonfly.h	(revision 215300)
+++ gcc/config/i386/dragonfly.h	(working copy)
@@ -89,9 +89,6 @@  see the files COPYING3 and COPYING.RUNTIME respect
 #undef TARGET_96_ROUND_53_LONG_DOUBLE
 #define TARGET_96_ROUND_53_LONG_DOUBLE (!TARGET_64BIT)
 
-/* Put all *tf routines in libgcc.  */
-#define LIBGCC2_TF_CEXT q
-
 /* Static stack checking is supported by means of probes.  */
 #define STACK_CHECK_STATIC_BUILTIN 1
 
Index: gcc/config/i386/freebsd.h
===================================================================
--- gcc/config/i386/freebsd.h	(revision 215300)
+++ gcc/config/i386/freebsd.h	(working copy)
@@ -131,9 +131,6 @@  along with GCC; see the file COPYING3.  If not see
 #undef TARGET_96_ROUND_53_LONG_DOUBLE
 #define TARGET_96_ROUND_53_LONG_DOUBLE (!TARGET_64BIT)
 
-/* Put all *tf routines in libgcc.  */
-#define LIBGCC2_TF_CEXT q
-
 /* Static stack checking is supported by means of probes.  */
 #define STACK_CHECK_STATIC_BUILTIN 1
 
Index: gcc/config/i386/gnu-user-common.h
===================================================================
--- gcc/config/i386/gnu-user-common.h	(revision 215300)
+++ gcc/config/i386/gnu-user-common.h	(working copy)
@@ -57,9 +57,6 @@  along with GCC; see the file COPYING3.  If not see
   GNU_USER_TARGET_MATHFILE_SPEC " " \
   GNU_USER_TARGET_ENDFILE_SPEC
 
-/* Put all *tf routines in libgcc.  */
-#define LIBGCC2_TF_CEXT q
-
 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
 
 /* The stack pointer needs to be moved while checking the stack.  */
Index: gcc/config/i386/openbsdelf.h
===================================================================
--- gcc/config/i386/openbsdelf.h	(revision 215300)
+++ gcc/config/i386/openbsdelf.h	(working copy)
@@ -111,6 +111,3 @@  along with GCC; see the file COPYING3.  If not see
 #define OBSD_HAS_CORRECT_SPECS
 
 #define HAVE_ENABLE_EXECUTE_STACK
-
-/* Put all *tf routines in libgcc.  */
-#define LIBGCC2_TF_CEXT q
Index: gcc/config/i386/sol2.h
===================================================================
--- gcc/config/i386/sol2.h	(revision 215300)
+++ gcc/config/i386/sol2.h	(working copy)
@@ -236,6 +236,3 @@  along with GCC; see the file COPYING3.  If not see
 #ifndef USE_GLD
 #define USE_HIDDEN_LINKONCE 0
 #endif
-
-/* Put all *tf routines in libgcc.  */
-#define LIBGCC2_TF_CEXT q
Index: gcc/config/ia64/ia64.h
===================================================================
--- gcc/config/ia64/ia64.h	(revision 215300)
+++ gcc/config/ia64/ia64.h	(working copy)
@@ -258,9 +258,6 @@  while (0)
 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE  (TARGET_ABI_OPEN_VMS ? 64 : 80)
 
 
-/* On HP-UX, we use the l suffix for TFmode in libgcc2.c.  */
-#define LIBGCC2_TF_CEXT l
-
 #define DEFAULT_SIGNED_CHAR 1
 
 /* A C expression for a string describing the name of the data type to use for
Index: gcc/config/ia64/linux.h
===================================================================
--- gcc/config/ia64/linux.h	(revision 215300)
+++ gcc/config/ia64/linux.h	(working copy)
@@ -76,10 +76,6 @@  do {						\
 #undef LINK_EH_SPEC
 #define LINK_EH_SPEC ""
 
-/* Put all *tf routines in libgcc.  */
-#undef LIBGCC2_TF_CEXT
-#define LIBGCC2_TF_CEXT q
-
 #undef TARGET_INIT_LIBFUNCS
 #define TARGET_INIT_LIBFUNCS ia64_soft_fp_init_libfuncs
 
Index: gcc/system.h
===================================================================
--- gcc/system.h	(revision 215300)
+++ gcc/system.h	(working copy)
@@ -936,7 +936,7 @@  extern void fancy_abort (const char *, int, const
 	EXTRA_CONSTRAINT_STR EXTRA_MEMORY_CONSTRAINT			   \
 	EXTRA_ADDRESS_CONSTRAINT CONST_DOUBLE_OK_FOR_CONSTRAINT_P	   \
 	CALLER_SAVE_PROFITABLE LARGEST_EXPONENT_IS_NORMAL		   \
-	ROUND_TOWARDS_ZERO SF_SIZE DF_SIZE XF_SIZE TF_SIZE
+	ROUND_TOWARDS_ZERO SF_SIZE DF_SIZE XF_SIZE TF_SIZE LIBGCC2_TF_CEXT
 
 /* Hooks that are no longer used.  */
  #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\
Index: libgcc/libgcc2.c
===================================================================
--- libgcc/libgcc2.c	(revision 215300)
+++ libgcc/libgcc2.c	(working copy)
@@ -1865,17 +1865,16 @@  NAME (TYPE x, int m)
 # define MTYPE	SFtype
 # define CTYPE	SCtype
 # define MODE	sc
-# define CEXT	f
+# define CEXT	__LIBGCC_SF_FUNC_EXT__
 # define NOTRUNC __FLT_EVAL_METHOD__ == 0
 #elif defined(L_muldc3) || defined(L_divdc3)
 # define MTYPE	DFtype
 # define CTYPE	DCtype
 # define MODE	dc
+# define CEXT	__LIBGCC_DF_FUNC_EXT__
 # if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 64
-#  define CEXT	l
 #  define NOTRUNC 1
 # else
-#  define CEXT
 #  define NOTRUNC __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 1
 # endif
 #elif defined(L_mulxc3) || defined(L_divxc3)
@@ -1882,17 +1881,13 @@  NAME (TYPE x, int m)
 # define MTYPE	XFtype
 # define CTYPE	XCtype
 # define MODE	xc
-# define CEXT	l
+# define CEXT	__LIBGCC_XF_FUNC_EXT__
 # define NOTRUNC 1
 #elif defined(L_multc3) || defined(L_divtc3)
 # define MTYPE	TFtype
 # define CTYPE	TCtype
 # define MODE	tc
-# if LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128
-#  define CEXT l
-# else
-#  define CEXT LIBGCC2_TF_CEXT
-# endif
+# define CEXT	__LIBGCC_TF_FUNC_EXT__
 # define NOTRUNC 1
 #else
 # error