[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patches] DFP Branch: S/390 support - take 2



Hello,

based on the patches before this is an updated version of the s390 DFP
support for eglibc.

Bye,

-Andreas-


2008-08-15  Andreas Krebbel  <krebbel1@xxxxxxxxxx>

	* dfp/sysdeps/unix/sysv/linux/s390/s390-64/z9-ec/fpu/Implies: New file.
	* dfp/sysdeps/unix/sysv/linux/s390/s390-64/z9-ec/Implies: New file.
	* dfp/sysdeps/s390/s390-64/z9-ec/fpu/Implies: New file.
	* dfp/sysdeps/unix/sysv/linux/s390/Implies: New file.
	* dfp/sysdeps/s390/dfpu/fe_decround.c: New file.
	* dfp/sysdeps/s390/dfpu/fenv_libc.h: New file.
	* dfp/sysdeps/s390/dfpu/fpu_control.h: New file.
	* dfp/sysdeps/s390/dfpu/numdigits.h: New file.


Index: dfp/sysdeps/unix/sysv/linux/s390/s390-64/z9-ec/fpu/Implies
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/unix/sysv/linux/s390/s390-64/z9-ec/fpu/Implies	2008-08-15 17:52:06.000000000 +0200
***************
*** 0 ****
--- 1 ----
+ s390/s390-64/z9-ec/fpu
Index: dfp/sysdeps/unix/sysv/linux/s390/s390-64/z9-ec/Implies
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/unix/sysv/linux/s390/s390-64/z9-ec/Implies	2008-08-15 17:52:06.000000000 +0200
***************
*** 0 ****
--- 1 ----
+ s390/dfpu
Index: dfp/sysdeps/s390/dfpu/fe_decround.c
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/s390/dfpu/fe_decround.c	2008-08-15 17:52:06.000000000 +0200
***************
*** 0 ****
--- 1,49 ----
+ /* Return current rounding direction.
+    Copyright (C) 2000, 2008 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+    Contributed by Denis Joseph Barrow (djbarrow@xxxxxxxxxx).
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+ 
+    The GNU C Library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+ 
+    You should have received a copy of the GNU Lesser General Public
+    License along with the GNU C Library; if not, write to the Free
+    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+    02111-1307 USA.  */
+ 
+ #include <fenv_libc.h>
+ #include <fpu_control.h>
+ 
+ int
+ __fe_dec_getround (void)
+ {
+   fexcept_t cw;
+ 
+   _FPU_GETCW (cw);
+ 
+   return cw & FPC_DFP_RM_MASK;
+ }
+ strong_alias(__fe_dec_getround, fe_dec_getround)
+ 
+ int
+ __fe_dec_setround (int round)
+ {
+   if ((round|FPC_DFP_RM_MASK) != FPC_DFP_RM_MASK)
+     {
+       /* ROUND is not a valid rounding mode.  */
+       return 1;
+     }
+   __asm__ volatile ("srnmt 0(%0)"
+ 		    :
+ 		    : "a" (round));
+ 
+   return 0;
+ }
+ strong_alias(__fe_dec_setround, fe_dec_setround)
Index: dfp/sysdeps/s390/dfpu/fenv_libc.h
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/s390/dfpu/fenv_libc.h	2008-08-15 17:52:06.000000000 +0200
***************
*** 0 ****
--- 1,44 ----
+ /* Copyright (C) 2000, 2008 Free Software Foundation, Inc.
+    This file is part of the GNU C Library.
+    Contributed by Denis Joseph Barrow (djbarrow@xxxxxxxxxx).
+ 
+    Adjusted for Decimal Floating Point by
+    Andreas Krebbel  <Andreas.Krebbel@xxxxxxxxxx>
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+ 
+    The GNU C Library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+ 
+    You should have received a copy of the GNU Lesser General Public
+    License along with the GNU C Library; if not, write to the Free
+    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+    02111-1307 USA.  */
+ 
+ #ifndef _FENV_LIBC_H
+ #define _FENV_LIBC_H    1
+ 
+ #include <fenv.h>
+ 
+ /* Definitions from asm/s390-regs-common.h that are needed in glibc.  */
+ 
+ 
+ #define FPC_EXCEPTION_MASK	0xF8000000
+ #define FPC_FLAGS_MASK		0x00F80000
+ #define FPC_DXC_MASK		0x0000FF00
+ #define FPC_RM_MASK		0x00000003
+ #define FPC_DFP_RM_MASK		0x000000E0
+ #define FPC_VALID_MASK		((FPC_EXCEPTION_MASK|FPC_FLAGS_MASK| \
+ 				 FPC_DXC_MASK|FPC_BFP_RM_MASK|FPC_DFP_RM_MASK))
+ 
+ #define FPC_EXCEPTION_MASK_SHIFT	24
+ #define FPC_FLAGS_SHIFT			16
+ #define FPC_DXC_SHIFT			8
+ #define FPC_NOT_FPU_EXCEPTION		0x300
+ 
+ #endif /* _FENV_LIBC_H */
Index: dfp/sysdeps/s390/dfpu/fpu_control.h
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/s390/dfpu/fpu_control.h	2008-08-15 17:52:06.000000000 +0200
***************
*** 0 ****
--- 1,50 ----
+ /* FPU control word definitions.  Stub version.
+    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 and 2008
+    Free Software Foundation, Inc.
+ 
+    Contributed by Denis Joseph Barrow (djbarrow@xxxxxxxxxx) and
+    Martin Schwidefsky (schwidefsky@xxxxxxxxxx).
+ 
+    Adjusted for Decimal Floating Point by
+    Andreas Krebbel  <Andreas.Krebbel@xxxxxxxxxx>
+ 
+    This file is part of the GNU C Library.
+ 
+    The GNU C Library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+ 
+    The GNU C Library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+ 
+    You should have received a copy of the GNU Lesser General Public
+    License along with the GNU C Library; if not, write to the Free
+    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+    02111-1307 USA.  */
+ 
+ #ifndef _FPU_CONTROL_H
+ # define _FPU_CONTROL_H
+ 
+ # include <features.h>
+ 
+ /* These bits are reserved are not changed.  */
+ # define _FPU_RESERVED 0x0707001C
+ 
+ /* The fdlibm code requires no interrupts for exceptions.  Don't
+    change the rounding mode, it would break long double I/O!  */
+ #define _FPU_DEFAULT  0x00000000 /* Default value.  */
+ 
+ /* Type of the control word.  */
+ typedef unsigned int fpu_control_t;
+ 
+ /* Macros for accessing the hardware control word.  */
+ #define _FPU_GETCW(cw)  __asm__ volatile ("efpc %0,0" : "=d" (cw))
+ #define _FPU_SETCW(cw)  __asm__ volatile ("sfpc  %0,0" : : "d" (cw))
+ 
+ /* Default control word set at startup.  */
+ extern fpu_control_t __fpu_control;
+ 
+ #endif /* _FPU_CONTROL_H */
Index: dfp/sysdeps/s390/dfpu/numdigits.h
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/s390/dfpu/numdigits.h	2008-08-15 17:52:06.000000000 +0200
***************
*** 0 ****
--- 1,155 ----
+ /* Number of digits functions, optimized for S/390 z9-ec.
+ 
+    Copyright (C) 2008 IBM Corporation.
+    Author(s): Andreas Krebbel  <Andreas.Krebbel@xxxxxxxxxx>
+ 
+    The Decimal Floating Point C Library is free software; you can
+    redistribute it and/or modify it under the terms of the GNU Lesser
+    General Public License version 2.1.
+ 
+    The Decimal Floating Point C Library is distributed in the hope that
+    it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+    the GNU Lesser General Public License version 2.1 for more details.
+ 
+    You should have received a copy of the GNU Lesser General Public
+    License version 2.1 along with the Decimal Floating Point C Library;
+    if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+    Suite 330, Boston, MA 02111-1307 USA.
+ 
+    Please see dfp/COPYING.txt for more information.  */
+ 
+ 
+ #ifndef _NUMDIGITS_H
+ #define _NUMDIGITS_H 1
+ 
+ 
+ #define NUMDIGITS_SUPPORT 1
+ 
+ #include "dpd-private.h"
+ 
+ #if _DECIMAL_SIZE == 32
+ // DECIMAL32 gets widened to DECIMAL64, so it ought to use DECIMAL64 bias
+ #  define DECIMAL_BIAS (101+297)
+ #elif _DECIMAL_SIZE == 64
+ #  define DECIMAL_BIAS 398
+ #elif _DECIMAL_SIZE == 128
+ #  define DECIMAL_BIAS 6176
+ #endif
+ 
+ 
+ static inline int
+ getexp (DEC_TYPE x)
+ {
+   int result;
+ 
+ #if _DECIMAL_SIZE == 32
+   _Decimal64 tmp = (_Decimal64)x;
+ #elif _DECIMAL_SIZE == 64
+   _Decimal64 tmp = x;
+ #elif _DECIMAL_SIZE == 128
+   register _Decimal128 tmp asm ("f0") = x;
+ #endif
+ 
+   asm (
+ #if _DECIMAL_SIZE == 128
+   "eextr %0,%1"
+ #else /* 32 and 64 bit */
+   "eedtr %0,%1"
+ #endif
+   : "=d"(result) : "f"(tmp));
+ 
+   return result - DECIMAL_BIAS;
+ }
+ 
+ 
+ static inline DEC_TYPE
+ setexp (DEC_TYPE x, int exp)
+ {
+ #if _DECIMAL_SIZE == 32
+   _Decimal64 tmp = (_Decimal64)x;
+ #elif _DECIMAL_SIZE == 128
+   register DEC_TYPE tmp asm ("f0") = x;
+ #else
+   DEC_TYPE tmp = x;
+ #endif
+ 
+   asm (
+ #if _DECIMAL_SIZE == 128
+     "iextr %0,%0,%1"
+ #else
+     "iedtr %0,%0,%1"
+ #endif
+     : "+f" (tmp) : "r" (exp + DECIMAL_BIAS));
+ 
+ #if _DECIMAL_SIZE == 32
+   return (_Decimal32)tmp;
+ #else
+   return tmp;
+ #endif
+ }
+ 
+ 
+ static inline int
+ numdigits (DEC_TYPE x)
+ {
+   int result;
+ 
+ #if _DECIMAL_SIZE == 128
+   register DEC_TYPE tmp asm ("f0") = x;
+ #elif _DECIMAL_SIZE == 32
+   _Decimal64 tmp = (_Decimal64)x;
+ #else
+   DEC_TYPE tmp = x;
+ #endif
+ 
+   asm (
+ #if _DECIMAL_SIZE == 128
+     "esxtr %0,%1"
+ #else /* 32 and 64 bit */
+     "esdtr %0,%1"
+ #endif
+    : "=d"(result) : "f"(tmp));
+ 
+   return result;
+ }
+ 
+ static DEC_TYPE
+ left_justify (DEC_TYPE x)
+ {
+ #if _DECIMAL_SIZE == 128
+   register DEC_TYPE tmp asm ("f0") = x;
+   register DEC_TYPE rnd asm ("f4");
+ #elif _DECIMAL_SIZE == 64
+   DEC_TYPE tmp = x;
+   DEC_TYPE rnd;
+ #else
+   _Decimal64 tmp = (_Decimal64)x;
+   _Decimal64 rnd;
+ #endif
+ 
+   int exp;
+ 
+   asm ("rrdtr %0,%2,%3,1\n\t"
+        "eedtr %1,%0\n\t"
+        /* The following magic numbers result from the precision of the
+ 	  data type minus 1.  */
+ #if _DECIMAL_SIZE == 32
+        "ahi %1,-6\n\t"
+ #elif _DECIMAL_SIZE == 64
+        "ahi %1,-15\n\t"
+ #else /* _DECIMAL_SIZE == 128 */
+        "ahi %1,-33\n\t"
+ #endif
+        "iedtr %0,%0,%1\n\t"
+        "qadtr %0,%2,%0,1" : "=f"(rnd), "=d"(exp), "+f"(tmp) : "d"(1));
+ 
+ #if _DECIMAL_SIZE == 32
+   return (_Decimal32)rnd;
+ #else
+   return rnd;
+ #endif
+ }
+ 
+ 
+ #endif /* _NUMDIGITS_H */
Index: dfp/sysdeps/s390/s390-64/z9-ec/fpu/Implies
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/s390/s390-64/z9-ec/fpu/Implies	2008-08-15 17:52:06.000000000 +0200
***************
*** 0 ****
--- 1 ----
+ dfp/libgcc-routines
Index: dfp/sysdeps/unix/sysv/linux/s390/Implies
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- dfp/sysdeps/unix/sysv/linux/s390/Implies	2008-08-15 17:55:34.000000000 +0200
***************
*** 0 ****
--- 1 ----
+ dfp/dpd