[PATCH] fix macro DEC_EVAL_METHOD for default, powerpc-linux

Janis Johnson janis187@us.ibm.com
Thu Apr 19 00:15:00 GMT 2007


WDTR 24732 specifies values for the macro DEC_EVAL_METHOD, which is
defined in <float.h> when the user has defined __STDC_WANT_DEC_FP__.
This patch causes the default value to be -1, for indeterminable, by
using that value for the default value of __DEC_EVAL_METHOD__ (note
the underscores), which is predefined by the compiler.  It overrides
that value for a powerpc*-unknown-linux-gnu target.  Furthermore, it
fixes the definition in <float.h> to use the correct macro name 
(instead of __DECFLT_EVAL_METHOD__) and in <float.h> also checks that
__DEC_EVAL_METHOD__ (with underscores) is defined.

Tested on powerpc64-unknown-linux-gnu with -m32/-m64.  OK for mainline?

2007-04-18  Janis Johnson  <janis187@us.ibm.com>

	* ginclude/float.h (DEC_EVAL_METHOD): Use correct name, default to
	-1 if compiler has not defined __DEC_EVAL_METHOD__.
	* defaults.h (TARGET_DEC_EVAL_METHOD): Define as -1.
	* config/rs6000/rs6000.h (TARGET_DEC_EVAL_METHOD): Define as 0.

testsuite/
	* gcc.dg/dfp/decfloat-constants.c: Check that the value of
	DEC_EVAL_METHOD is in the valid range.

Index: gcc/ginclude/float.h
===================================================================
--- gcc/ginclude/float.h	(revision 123951)
+++ gcc/ginclude/float.h	(working copy)
@@ -233,8 +233,11 @@
 	 2  evaluate all operations and constants to the range and
 	    precision of the _Decimal128 type.  */
 
-#undef DECFLT_EVAL_METHOD
-#define DECFLT_EVAL_METHOD	__DECFLT_EVAL_METHOD__
+#ifdef __DEC_EVAL_METHOD__
+#define DEC_EVAL_METHOD __DEC_EVAL_METHOD__
+#else
+#define DEC_EVAL_METHOD -1
+#endif
 
 #endif /* __STDC_WANT_DEC_FP__ == 1 */
 
Index: gcc/defaults.h
===================================================================
--- gcc/defaults.h	(revision 123951)
+++ gcc/defaults.h	(working copy)
@@ -687,7 +687,7 @@
 #endif
 
 #ifndef TARGET_DEC_EVAL_METHOD
-#define TARGET_DEC_EVAL_METHOD 2
+#define TARGET_DEC_EVAL_METHOD -1
 #endif
 
 #ifndef HOT_TEXT_SECTION_NAME
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	(revision 123951)
+++ gcc/config/rs6000/rs6000.h	(working copy)
@@ -50,6 +50,13 @@
 #define TARGET_CPU_DEFAULT ((char *)0)
 #endif
 
+/* Set the value of DEC_EVAL_METHOD in float.h.  Software emulation
+   using decNumber performs evaluation to the range and precision of
+   the type.  */
+#ifndef TARGET_DEC_EVAL_METHOD
+#define TARGET_DEC_EVAL_METHOD 0
+#endif
+
 /* If configured for PPC405, support PPC405CR Erratum77.  */
 #ifdef CONFIG_PPC405CR
 #define PPC405_ERRATUM77 (rs6000_cpu == PROCESSOR_PPC405)
Index: gcc/testsuite/gcc.dg/dfp/decfloat-constants.c
===================================================================
--- gcc/testsuite/gcc.dg/dfp/decfloat-constants.c	(revision 123951)
+++ gcc/testsuite/gcc.dg/dfp/decfloat-constants.c	(working copy)
@@ -45,5 +45,7 @@
   if (DEC64_DEN != 0.000000000000001E-383DD) abort();
   if (DEC128_DEN != 0.000000000000000000000000000000001E-6143DL) abort();
 
+  if (DEC_EVAL_METHOD < -1 || DEC_EVAL_METHOD > 2) abort ();
+
   return 0;
 }



More information about the Gcc-patches mailing list