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

[Commits] r19822 - in /libdfp/trunk: ChangeLog Makefile.in sysdeps/powerpc/dfpu/numdigits.h tests/test-decode.c tests/test-getexp.c



Author: ryanarn
Date: Wed Jul 25 18:19:55 2012
New Revision: 19822

Log:
2012-07-25  Ryan S. Arnold  <rsa@xxxxxxxxxxxxxxxxxx>

	* Makefile.in (libdfp_c_tests): Added test-getexp.
	* tests/test-getexp.c: New test.
	* tests/test-decode.c (d64types): Added test for __DEC64_MAX__ and
	__DEC64_MIN__.
	* sysdeps/powerpc/dfpu/numdigits.h (getexpd[32|64|128]): Fixed in
	order to prevent erroneous sign extension due to using stfiwx.


Added:
    libdfp/trunk/tests/test-getexp.c
Modified:
    libdfp/trunk/ChangeLog
    libdfp/trunk/Makefile.in
    libdfp/trunk/sysdeps/powerpc/dfpu/numdigits.h
    libdfp/trunk/tests/test-decode.c

Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Wed Jul 25 18:19:55 2012
@@ -1,3 +1,12 @@
+2012-07-25  Ryan S. Arnold  <rsa@xxxxxxxxxxxxxxxxxx>
+
+	* Makefile.in (libdfp_c_tests): Added test-getexp.
+	* tests/test-getexp.c: New test.
+	* tests/test-decode.c (d64types): Added test for __DEC64_MAX__ and
+	__DEC64_MIN__.
+	* sysdeps/powerpc/dfpu/numdigits.h (getexpd[32|64|128]): Fixed in
+	order to prevent erroneous sign extension due to using stfiwx.
+
 2012-07-25  Ryan S. Arnold  <rsa@xxxxxxxxxxxxxxxxxx>
 
 	* sysdeps/powerpc/dfpu/numdigits.h: Cleaned up inline asm DEC_TYPE

Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Wed Jul 25 18:19:55 2012
@@ -335,13 +335,13 @@
 		 test-isnan test-isinf test-isfinite test-fpclassify test-logd \
 		 test-log10d test-strtod test-numdigits test-get_digits \
 		 test-round test-bfp-conversions test-stdlib test-wchar \
-		 test-expd test-GCC-PR52140
+		 test-expd test-GCC-PR52140 test-getexp
 
 libdfp_cxx_tests = test-ostream test-ostream-g-spec test-istream
 
 libdfp_tests = $(libdfp_c_tests) $(libdfp_cxx_tests)
 
-CFLAGS-test-param.c += -O0
+test-printf.os: $(top_builddir)/printf_dfp.os
 
 # Empty rule which simply makes the libdfp_tests .so's dependent on
 # tests/scaffold.c so that when the scaffold file changes all of the test .so
@@ -395,7 +395,7 @@
 # We use debug-test.conf as an input file for some debugging utilities.  The
 # .out files are predicated in another rule on the actual test executables, so
 # those are built from those rules.
-check: $(top_builddir)/printf_dfp.o $(top_builddir)/debug-test.conf $(addsuffix .conf,$(libdfp_tests)) $(addsuffix .out,$(libdfp_tests))
+check: $(top_builddir)/debug-test.conf $(addsuffix .conf,$(libdfp_tests)) $(addsuffix .out,$(libdfp_tests))
 	@echo +Completed make check
 
 .PHONY: check

Modified: libdfp/trunk/sysdeps/powerpc/dfpu/numdigits.h
==============================================================================
--- libdfp/trunk/sysdeps/powerpc/dfpu/numdigits.h (original)
+++ libdfp/trunk/sysdeps/powerpc/dfpu/numdigits.h Wed Jul 25 18:19:55 2012
@@ -68,18 +68,16 @@
 FUNC_D (getexp) (DEC_TYPE x)
 {
   double f;
-  int i;
+  long long i;
 #if _DECIMAL_SIZE == 32
   asm ("dctdp %0,%1\n\t"
        "dxex %0,%0\n\t" : "=d"(f) : "f"(x));
 #elif _DECIMAL_SIZE == 64
   asm ("dxex %0,%1" : "=d"(f) : "d"(x));
 #elif _DECIMAL_SIZE == 128
-  //register DEC_TYPE tmp asm ("fr0") = x;
-  DEC_TYPE tmp = x;
-  asm ("dxexq %0,%1" : "=d"(f) : "d"(tmp));
-#endif
-  asm ("stfiwx %1,%y0" : "=Z"(i) : "d"(f));
+  asm ("dxexq %0,%1" : "=d"(f) : "d"(x));
+#endif
+  asm ("stfd %1,%0" : "=m"(i) : "d"(f));
   return i - DECIMAL_BIAS;
 }
 

Modified: libdfp/trunk/tests/test-decode.c
==============================================================================
--- libdfp/trunk/tests/test-decode.c (original)
+++ libdfp/trunk/tests/test-decode.c Wed Jul 25 18:19:55 2012
@@ -74,6 +74,7 @@
     {
 #ifdef _DPD_BACKEND
       {__LINE__,1.00DD, "+0,000,000,000,000,100E-2"},
+      {__LINE__,__DEC64_MIN__, "+0,000,000,000,000,001E-383"},
       {__LINE__,__DEC64_MAX__, "+9,999,999,999,999,999E+369"},
       {__LINE__,-DEC_NAN, "-0,000,000,000,000,000E-398"},
       {__LINE__,9.999999999999999E369DD, "+9,999,999,999,999,999E+354"},

Added: libdfp/trunk/tests/test-getexp.c
==============================================================================
--- libdfp/trunk/tests/test-getexp.c (added)
+++ libdfp/trunk/tests/test-getexp.c Wed Jul 25 18:19:55 2012
@@ -1,0 +1,162 @@
+/* Unit test the internal getexpd[32|64|128]() functions.
+
+   Copyright (C) 2012 Free Software Foundation, Inc.
+
+   This file is part of the Decimal Floating Point C Library.
+
+   Author(s): Ryan S. Arnold <rsa@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 libdfp/COPYING.txt for more information.  */
+
+#ifndef __STDC_WANT_DEC_FP__
+#define __STDC_WANT_DEC_FP__
+#endif
+
+#include <float.h> /* DEC_NAN definition.  */
+#include <stdio.h>
+#include <math.h>
+
+#include <get_digits.h>
+#define _DECIMAL_SIZE 32
+#define DEC_TYPE _Decimal32
+#include <numdigits.h>
+#undef _DECIMAL_SIZE
+#undef DEC_TYPE
+#undef ADJUST
+#undef Q
+#undef DECIMAL_BIAS
+#define _DECIMAL_SIZE 64
+#define DEC_TYPE _Decimal64
+#include <numdigits.h>
+#undef _DECIMAL_SIZE
+#undef DEC_TYPE
+#undef ADJUST
+#undef Q
+#undef DECIMAL_BIAS
+#define _DECIMAL_SIZE 128
+#define DEC_TYPE _Decimal128
+#include <numdigits.h>
+
+#define _WANT_VC 1 /* Pick up the _VC_P(x,y,fmt) macro.  */
+#include "scaffold.c" /* Pick up the _VC_P(x,y,fmt) macro.  */
+
+/* We're going to be comparing fields so we need to extract the data.  This is a
+ * sneaky way to get around the fact that get_digits_d* isn't exported from
+ * libdfp.  */
+#include "../sysdeps/dpd/dpd-private.c"
+
+/* Inspired by GLIBC stdio-common/tfformat.c  */
+typedef struct{
+  int line;
+  _Decimal128 x;  /* Value to test  */
+  int e;  /* Result should be this.  */
+  const char *format; /* printf %d */
+} d128_type;
+
+d128_type printf_d128s[] =
+{
+  {0,0,0,0 }
+};
+
+typedef struct{
+  int line;
+  _Decimal64 x;  /* Value to test  */
+  int e;  /* Result should be this.  */
+  const char *format; /* printf %d */
+} d64_type;
+
+/* getexpd* will return __NAND*__ if the input is a NAN.  */
+#define __NAND32__ -399
+#define __NAND64__ -399
+#define __NAND128__ -399
+
+d64_type printf_d64s[] =
+{
+  {__LINE__, 4e384DD, 369, "%d"},
+  {__LINE__, 4000000000000000e369DD, 369, "%d"},
+  {__LINE__, 4000000000000000e370DD, __NAND64__, "%d"},
+  {__LINE__, __DEC64_MAX__, 369, "%d"},
+  {__LINE__, __DEC64_MIN__, -383, "%d" }, 
+  {0,0,0,0 }
+};
+
+typedef struct{
+  int line;
+  _Decimal32 x;  /* Value to test  */
+  int e;  /* Result should be this.  */
+  const char *format; /* printf %d */
+} d32_type;
+
+d32_type printf_d32s[] =
+{
+  {0,0,0,0 }
+};
+
+int ged128 (_Decimal128 d);
+int ged64 (_Decimal64 d);
+int ged32 (_Decimal32 d);
+
+/* Use these so that the inline function is inlined into a wrapper function
+ * for easier debugging.  */
+int ged128(_Decimal128 d)
+{
+	return getexpd128(d);
+}
+int ged64(_Decimal64 d)
+{
+	return getexpd64(d);
+}
+
+int ged32(_Decimal32 d)
+{
+	return getexpd32(d);
+}
+
+int main (void)
+{
+  d128_type *d128ptr;
+  d64_type *d64ptr;
+  d32_type *d32ptr;
+
+  for (d128ptr = printf_d128s; d128ptr->line; d128ptr++)
+    {
+      int retval = ged128(d128ptr->x);
+      fprintf(stdout,"getexpd128(%DDfDL) in: %s:%d\n", d128ptr->x,__FILE__,__LINE__-1);
+      _VC_P(__FILE__,d128ptr->line, d128ptr->e,retval,d128ptr->format);
+    }
+
+  for (d64ptr = printf_d64s; d64ptr->line; d64ptr++)
+    {
+      int retval = ged64(d64ptr->x);
+      fprintf(stdout,"getexpd64(%DfDD) in: %s:%d\n", d64ptr->x,__FILE__,__LINE__-1);
+      _VC_P(__FILE__,d64ptr->line, d64ptr->e,retval,d64ptr->format);
+    }
+
+  for (d32ptr = printf_d32s; d32ptr->line; d32ptr++)
+    {
+      int retval = ged32(d32ptr->x);
+      fprintf(stdout,"getexpd32(%HfDF) in: %s:%d\n", d32ptr->x,__FILE__,__LINE__-1);
+      _VC_P(__FILE__,d32ptr->line, d32ptr->e,retval,d32ptr->format);
+    }
+
+  _REPORT();
+
+  /* fail comes from scaffold.c  */
+  return fail;
+}
+
+

_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits