This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: handle decimal float modes on ia32/x86-64
- From: Ben Elliston <bje at au1 dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: jh at suse dot cz, rth at redhat dot com
- Date: Wed, 1 Feb 2006 09:55:36 +1100
- Subject: PATCH: handle decimal float modes on ia32/x86-64
This patch adds ia32 and x86-64 backend support for the decimal float
modes. The x86-64 patch conforms to the recent additions to the
x86-64 ABI for decimal floating point types, passing via SSE
registers.
These changes have been tested with the requisite t-* Makefile changes
to activate them, but I am not submitting those here. Tested with a
bootstrap and regression test run on i686-pc-linux-gnu and
x64_64-unknown-linux-gnu.
The change to i386.h is required for the dfp runtime routines.
Okay for the trunk?
Ben
2006-02-01 Ben Elliston <bje@au.ibm.com>
* config/i386/i386.h (LIBGCC2_WORDS_BIG_ENDIAN): Define.
* config/i386/i386.c (ix86_scalar_mode_supported_p): New.
(TARGET_SCALAR_MODE_SUPPORTED_P): Define hook.
(classify_argument): Handle SDmode, DDmode, TDmode.
(ix86_return_in_memory): Handle TDmode.
(ix86_libcall_value): Handle SDmode, DDmode, TDmode.
(ix86_value_regno): Return non-TDmode decimal float modes in %eax.
Index: i386.h
===================================================================
--- i386.h (revision 110412)
+++ i386.h (working copy)
@@ -536,6 +536,9 @@ extern int x86_prefetch_sse;
numbered. */
/* Not true for 80386 */
#define WORDS_BIG_ENDIAN 0
+#ifdef IN_LIBGCC2
+#define LIBGCC2_WORDS_BIG_ENDIAN 0
+#endif /* IN_LIBGCC2 */
/* Width of a word, in units (bytes). */
#define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4)
Index: i386.c
===================================================================
--- i386.c (revision 110412)
+++ i386.c (working copy)
@@ -1095,6 +1095,7 @@ static tree ix86_build_builtin_va_list (
static void ix86_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
tree, int *, int);
static tree ix86_gimplify_va_arg (tree, tree, tree *, tree *);
+static bool ix86_scalar_mode_supported_p (enum machine_mode);
static bool ix86_vector_mode_supported_p (enum machine_mode);
static int ix86_address_cost (rtx);
@@ -1320,6 +1321,9 @@ static section *x86_64_elf_select_sectio
#undef TARGET_GIMPLIFY_VA_ARG_EXPR
#define TARGET_GIMPLIFY_VA_ARG_EXPR ix86_gimplify_va_arg
+#undef TARGET_SCALAR_MODE_SUPPORTED_P
+#define TARGET_SCALAR_MODE_SUPPORTED_P ix86_scalar_mode_supported_p
+
#undef TARGET_VECTOR_MODE_SUPPORTED_P
#define TARGET_VECTOR_MODE_SUPPORTED_P ix86_vector_mode_supported_p
@@ -3053,6 +3057,14 @@ classify_argument (enum machine_mode mod
/* Classification of atomic types. */
switch (mode)
{
+ case SDmode:
+ case DDmode:
+ classes[0] = X86_64_SSE_CLASS;
+ return 1;
+ case TDmode:
+ classes[0] = X86_64_SSE_CLASS;
+ classes[1] = X86_64_SSEUP_CLASS;
+ return 2;
case DImode:
case SImode:
case HImode:
@@ -3796,6 +3808,9 @@ ix86_return_in_memory (tree type)
if (mode == XFmode)
return 0;
+ if (mode == TDmode)
+ return 1;
+
if (size > 12)
return 1;
return 0;
@@ -3861,6 +3876,9 @@ ix86_libcall_value (enum machine_mode mo
case DFmode:
case DCmode:
case TFmode:
+ case SDmode:
+ case DDmode:
+ case TDmode:
return gen_rtx_REG (mode, FIRST_SSE_REG);
case XFmode:
case XCmode:
@@ -3892,6 +3910,10 @@ ix86_value_regno (enum machine_mode mode
if (mode == TImode || (VECTOR_MODE_P (mode) && GET_MODE_SIZE (mode) == 16))
return FIRST_SSE_REG;
+ /* Decimal floating point values can go in %eax, unlike other float modes. */
+ if (DECIMAL_FLOAT_MODE_P (mode))
+ return 0;
+
/* Most things go in %eax, except (unless -mno-fp-ret-in-387) fp values. */
if (!SCALAR_FLOAT_MODE_P (mode) || !TARGET_FLOAT_RETURNS_IN_80387)
return 0;
@@ -18303,6 +18325,16 @@ ix86_expand_reduc_v4sf (rtx (*fn) (rtx,
emit_insn (fn (dest, tmp2, tmp3));
}
+/* Target hook for scalar_mode_supported_p. */
+static bool
+ix86_scalar_mode_supported_p (enum machine_mode mode)
+{
+ if (DECIMAL_FLOAT_MODE_P (mode))
+ return true;
+ else
+ return default_scalar_mode_supported_p (mode);
+}
+
/* Implements target hook vector_mode_supported_p. */
static bool
ix86_vector_mode_supported_p (enum machine_mode mode)