diff mbox

[4/11] Implement TARGET_C_EXCESS_PRECISION for m68k

Message ID 1475254915-11078-1-git-send-email-james.greenhalgh@arm.com
State New
Headers show

Commit Message

James Greenhalgh Sept. 30, 2016, 5:01 p.m. UTC
Hi,

This patch ports the logic from m68k's TARGET_FLT_EVAL_METHOD to the new
target hook TARGET_C_EXCESS_PRECISION.

Patch tested by building an m68k-none-elf toolchain and running
m68k.exp (without the ability to execute) with no regressions, and manually
inspecting the output assembly code when compiling
testsuite/gcc.target/i386/excess-precision* to show no difference in
code-generation.

OK?

Thanks,
James

---
gcc/

2016-09-30  James Greenhalgh  <james.greenhalgh@arm.com>

	* config/m68k/m68k.c (m68k_excess_precision): New.
	(TARGET_C_EXCESS_PRECISION): Define.

Comments

Jeff Law Sept. 30, 2016, 5:28 p.m. UTC | #1
On 09/30/2016 11:01 AM, James Greenhalgh wrote:
>
> Hi,
>
> This patch ports the logic from m68k's TARGET_FLT_EVAL_METHOD to the new
> target hook TARGET_C_EXCESS_PRECISION.
>
> Patch tested by building an m68k-none-elf toolchain and running
> m68k.exp (without the ability to execute) with no regressions, and manually
> inspecting the output assembly code when compiling
> testsuite/gcc.target/i386/excess-precision* to show no difference in
> code-generation.
>
> OK?
>
> Thanks,
> James
>
> ---
> gcc/
>
> 2016-09-30  James Greenhalgh  <james.greenhalgh@arm.com>
>
> 	* config/m68k/m68k.c (m68k_excess_precision): New.
> 	(TARGET_C_EXCESS_PRECISION): Define.
OK when prereqs are approved.  Similarly for other targets where you 
needed to add this hook.

jeff
Andreas Schwab Sept. 30, 2016, 6:05 p.m. UTC | #2
On Sep 30 2016, James Greenhalgh <james.greenhalgh@arm.com> wrote:

> 	* config/m68k/m68k.c (m68k_excess_precision): New.
> 	(TARGET_C_EXCESS_PRECISION): Define.

Ok.

Andreas.
diff mbox

Patch

diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index a104193..c858d7e 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -182,6 +182,8 @@  static rtx m68k_function_arg (cumulative_args_t, machine_mode,
 static bool m68k_cannot_force_const_mem (machine_mode mode, rtx x);
 static bool m68k_output_addr_const_extra (FILE *, rtx);
 static void m68k_init_sync_libfuncs (void) ATTRIBUTE_UNUSED;
+static enum flt_eval_method
+m68k_excess_precision (enum excess_precision_type);
 
 /* Initialize the GCC target structure.  */
 
@@ -322,6 +324,9 @@  static void m68k_init_sync_libfuncs (void) ATTRIBUTE_UNUSED;
 #undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
 #define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA m68k_output_addr_const_extra
 
+#undef TARGET_EXCESS_PRECISION
+#define TARGET_EXCESS_PRECISION m68k_excess_precision
+
 /* The value stored by TAS.  */
 #undef TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
 #define TARGET_ATOMIC_TEST_AND_SET_TRUEVAL 128
@@ -6528,4 +6533,36 @@  m68k_epilogue_uses (int regno ATTRIBUTE_UNUSED)
 	      == m68k_fk_interrupt_handler));
 }
 
+
+/* Implement TARGET_EXCESS_PRECISION.
+
+   Set the value of FLT_EVAL_METHOD in float.h.  When using 68040 fp
+   instructions, we get proper intermediate rounding, otherwise we
+   get extended precision results.  */
+
+static enum flt_eval_method
+m68k_excess_precision (enum excess_precision_type type)
+{
+  switch (type)
+    {
+      case EXCESS_PRECISION_TYPE_FAST:
+	/* The fastest type to promote to will always be the native type,
+	   whether that occurs with implicit excess precision or
+	   otherwise.  */
+	return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT;
+      case EXCESS_PRECISION_TYPE_STANDARD:
+      case EXCESS_PRECISION_TYPE_IMPLICIT:
+	/* Otherwise, the excess precision we want when we are
+	   in a standards compliant mode, and the implicit precision we
+	   provide can be identical.  */
+	if (TARGET_68040 || ! TARGET_68881)
+	  return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT;
+
+	return FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE;
+      default:
+	gcc_unreachable ();
+    }
+  return FLT_EVAL_METHOD_UNPREDICTABLE;
+}
+
 #include "gt-m68k.h"