[PATCH] S/390: DFP support 1/4: Add z9-ec option

Andreas Krebbel krebbel1@de.ibm.com
Fri Mar 16 19:00:00 GMT 2007


Hi,

the latest zSeries mainframe "IBM System z9 Enterprise Class" provides instructions 
handling decimal floating point numbers:
http://www.research.ibm.com/journal/rd/511/duale.html

More background about dfp numbers can be found here:
http://www2.hursley.ibm.com/decimal/

The attached patch is the first of a patchset adding dfp hardware support to the
s390 gcc back end.  The new instructions are documented here:
http://publibfi.boulder.ibm.com/epubs/pdf/a2322320.pdf

The necessary binutils patch is already committed:
http://sourceware.org/ml/binutils/2007-03/msg00037.html

That first patch of the series adds the new architecture switch z9-ec together with
the -mhard-dfp and -msoft-dfp switches.  The architecture switch can be used via
-march=z9-ec to enable zSeries hardware dfp support.

Bootstrapped on s390 and s390x.
No testsuite regression occured. 
Most of the dectest dfp tests were successful - I've looked in a few failing cases
and found that the failures were caused by missing glibc "set rounding mode" support.

OK for mainline?

Bye,

-Andreas-



2007-03-16  Andreas Krebbel  <krebbel1@de.ibm.com>

	* config/s390/s390.opt ("mhard-float", "msoft-float"): Bit value
	inverted and documentation adjusted.
	("mhard-dfp", "msoft-dfp"): New options.
	* config/s390/s390.c (s390_handle_arch_option): New architecture
	switch: z9-ec.
	(override_options): Sanity checks for the new options added.
	* config.gcc: New architecture switch: z9-ec.
	* config/s390/s390.h (processor_flags): PF_DFP added.
	(TARGET_CPU_DFP, TARGET_DFP): Macro definitions added.
	(TARGET_DEFAULT): Due to the s390.opt changes hard float is enabled
	when the bit is NOT set so remove it from the defaults.



Index: gcc/config/s390/s390.opt
===================================================================
*** gcc/config/s390/s390.opt.orig	2007-03-15 17:33:47.000000000 +0100
--- gcc/config/s390/s390.opt	2007-03-16 09:21:00.000000000 +0100
*************** mfused-madd
*** 47,55 ****
  Target Report Mask(FUSED_MADD)
  Enable fused multiply/add instructions
  
  mhard-float
! Target Report RejectNegative Mask(HARD_FLOAT)
! Use hardware fp
  
  mlong-double-128
  Target Report RejectNegative Mask(LONG_DOUBLE_128)
--- 47,59 ----
  Target Report Mask(FUSED_MADD)
  Enable fused multiply/add instructions
  
+ mhard-dfp
+ Target Report RejectNegative InverseMask(SOFT_DFP, HARD_DFP)
+ Enable hardware decimal floating point
+ 
  mhard-float
! Target Report RejectNegative InverseMask(SOFT_FLOAT, HARD_FLOAT)
! Enable hardware floating point
  
  mlong-double-128
  Target Report RejectNegative Mask(LONG_DOUBLE_128)
*************** msmall-exec
*** 67,75 ****
  Target Report Mask(SMALL_EXEC)
  Use bras for executable < 64k
  
  msoft-float
! Target Report RejectNegative InverseMask(HARD_FLOAT, SOFT_FLOAT)
! Don't use hardware fp
  
  mstack-guard=
  Target RejectNegative Joined
--- 71,83 ----
  Target Report Mask(SMALL_EXEC)
  Use bras for executable < 64k
  
+ msoft-dfp
+ Target Report RejectNegative Mask(SOFT_DFP)
+ Disable hardware decimal floating point
+ 
  msoft-float
! Target Report RejectNegative Mask(SOFT_FLOAT)
! Disable hardware floating point
  
  mstack-guard=
  Target RejectNegative Joined
Index: gcc/config/s390/s390.c
===================================================================
*** gcc/config/s390/s390.c.orig	2007-03-15 17:33:47.000000000 +0100
--- gcc/config/s390/s390.c	2007-03-16 09:31:35.000000000 +0100
*************** s390_handle_arch_option (const char *arg
*** 1340,1345 ****
--- 1340,1347 ----
  				    | PF_LONG_DISPLACEMENT},
        {"z9-109", PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
                                         | PF_LONG_DISPLACEMENT | PF_EXTIMM},
+       {"z9-ec", PROCESSOR_2094_Z9_109, PF_IEEE_FLOAT | PF_ZARCH
+                              | PF_LONG_DISPLACEMENT | PF_EXTIMM | PF_DFP },
      };
    size_t i;
  
*************** override_options (void)
*** 1418,1428 ****
      }
  
    /* Sanity checks.  */
!   if (TARGET_ZARCH && !(s390_arch_flags & PF_ZARCH))
      error ("z/Architecture mode not supported on %s", s390_arch_string);
    if (TARGET_64BIT && !TARGET_ZARCH)
      error ("64-bit ABI not supported in ESA/390 mode");
  
    /* Set processor cost function.  */
    if (s390_tune == PROCESSOR_2094_Z9_109)
      s390_cost = &z9_109_cost;
--- 1420,1453 ----
      }
  
    /* Sanity checks.  */
!   if (TARGET_ZARCH && !TARGET_CPU_ZARCH)
      error ("z/Architecture mode not supported on %s", s390_arch_string);
    if (TARGET_64BIT && !TARGET_ZARCH)
      error ("64-bit ABI not supported in ESA/390 mode");
  
+   if (TARGET_HARD_DFP && (!TARGET_CPU_DFP || !TARGET_ZARCH))
+     {
+       if (target_flags_explicit & MASK_SOFT_DFP)
+ 	{
+ 	  if (!TARGET_CPU_DFP)
+ 	    error ("Hardware decimal floating point instructions"
+ 		   " not available on %s", s390_arch_string);
+ 	  if (!TARGET_ZARCH)
+ 	    error ("Hardware decimal floating point instructions"
+ 		   " not available in ESA/390 mode");
+ 	}
+       else
+ 	target_flags |= MASK_SOFT_DFP;
+     }
+ 
+   if ((target_flags_explicit & MASK_SOFT_FLOAT) && TARGET_SOFT_FLOAT)
+     {
+       if ((target_flags_explicit & MASK_SOFT_DFP) && TARGET_HARD_DFP)
+ 	error ("-mhard-dfp can't be used in conjunction with -msoft-float");
+ 
+       target_flags |= MASK_SOFT_DFP;
+     }
+ 
    /* Set processor cost function.  */
    if (s390_tune == PROCESSOR_2094_Z9_109)
      s390_cost = &z9_109_cost;
Index: gcc/config/s390/s390.md
===================================================================
*** gcc/config/s390/s390.md.orig	2007-03-15 17:33:47.000000000 +0100
--- gcc/config/s390/s390.md	2007-03-15 17:33:49.000000000 +0100
***************
*** 195,201 ****
  ;; this description is also used for the g5 and g6.
  (include "2064.md")
  
! ;; Pipeline description for z990. 
  (include "2084.md")
  
  ;; Predicates
--- 195,201 ----
  ;; this description is also used for the g5 and g6.
  (include "2064.md")
  
! ;; Pipeline description for z990, z9-109 and z9-ec.
  (include "2084.md")
  
  ;; Predicates
Index: gcc/config.gcc
===================================================================
*** gcc/config.gcc.orig	2007-03-15 17:33:47.000000000 +0100
--- gcc/config.gcc	2007-03-15 17:33:49.000000000 +0100
*************** case "${target}" in
*** 3017,3023 ****
  		for which in arch tune; do
  			eval "val=\$with_$which"
  			case ${val} in
! 			"" | g5 | g6 | z900 | z990 | z9-109)
  				# OK
  				;;
  			*)
--- 3017,3023 ----
  		for which in arch tune; do
  			eval "val=\$with_$which"
  			case ${val} in
! 			"" | g5 | g6 | z900 | z990 | z9-109 | z9-ec)
  				# OK
  				;;
  			*)
Index: gcc/config/s390/s390.h
===================================================================
*** gcc/config/s390/s390.h.orig	2007-03-15 17:33:47.000000000 +0100
--- gcc/config/s390/s390.h	2007-03-16 09:21:37.000000000 +0100
*************** enum processor_flags
*** 51,57 ****
    PF_IEEE_FLOAT = 1,
    PF_ZARCH = 2,
    PF_LONG_DISPLACEMENT = 4,
!   PF_EXTIMM = 8
  };
  
  extern enum processor_type s390_tune;
--- 51,58 ----
    PF_IEEE_FLOAT = 1,
    PF_ZARCH = 2,
    PF_LONG_DISPLACEMENT = 4,
!   PF_EXTIMM = 8,
!   PF_DFP = 16
  };
  
  extern enum processor_type s390_tune;
*************** extern enum processor_flags s390_arch_fl
*** 68,78 ****
--- 69,83 ----
  	(s390_arch_flags & PF_LONG_DISPLACEMENT)
  #define TARGET_CPU_EXTIMM \
   	(s390_arch_flags & PF_EXTIMM)
+ #define TARGET_CPU_DFP \
+  	(s390_arch_flags & PF_DFP)
  
  #define TARGET_LONG_DISPLACEMENT \
         (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT)
  #define TARGET_EXTIMM \
         (TARGET_ZARCH && TARGET_CPU_EXTIMM)
+ #define TARGET_DFP \
+        (TARGET_ZARCH && TARGET_CPU_DFP)
  
  /* Run-time target specification.  */
  
*************** extern enum processor_flags s390_arch_fl
*** 103,111 ****
  #define TARGET_IEEE_FLOAT          1
  
  #ifdef DEFAULT_TARGET_64BIT
! #define TARGET_DEFAULT             (MASK_64BIT | MASK_ZARCH | MASK_HARD_FLOAT)
  #else
! #define TARGET_DEFAULT             MASK_HARD_FLOAT
  #endif
  
  /* Support for configure-time defaults.  */
--- 108,116 ----
  #define TARGET_IEEE_FLOAT          1
  
  #ifdef DEFAULT_TARGET_64BIT
! #define TARGET_DEFAULT             (MASK_64BIT | MASK_ZARCH)
  #else
! #define TARGET_DEFAULT             0
  #endif
  
  /* Support for configure-time defaults.  */



More information about the Gcc-patches mailing list