]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Remove CHOOSE() macro from libm-tests.inc
authorPaul E. Murphy <murphyp@linux.vnet.ibm.com>
Wed, 8 Jun 2016 19:37:15 +0000 (14:37 -0500)
committerPaul E. Murphy <murphyp@linux.vnet.ibm.com>
Wed, 8 Jun 2016 19:37:15 +0000 (14:37 -0500)
Use gen-libm-test.pl to generate a list of macros
mapping to libm-test-ulps.h as this simplifies adding new
types without having to modify a growing number of
static headers each time a type is added.

This also removes the final usage of the TEST_(DOUBLE|FLOAT|LDOUBLE)
macros.  Thus, they too are removed.

21 files changed:
ChangeLog
math/gen-libm-test.pl
math/libm-test.inc
math/test-double-finite.c
math/test-double-vlen2.h
math/test-double-vlen4.h
math/test-double-vlen8.h
math/test-double.c
math/test-double.h
math/test-float-finite.c
math/test-float-vlen16.h
math/test-float-vlen4.h
math/test-float-vlen8.h
math/test-float.c
math/test-float.h
math/test-idouble.c
math/test-ifloat.c
math/test-ildoubl.c
math/test-ldouble-finite.c
math/test-ldouble.c
math/test-ldouble.h

index 924f6fd0e20a2c3d6fdc0660f6040be87d1edcc2..8df2095985f4852eed3dd974cb92d8c08c3e7d8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2016-06-08  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
+
+       * math/gen-libm-test.pl (all_floats_pfx): New lookup table.
+       (parse_ulps): Dynamically generate type name matching
+       string from all_floats.
+       (get_ulps): Generate the ulps as an array instead.
+       (output_ulps): Dynamically compose the type based
+       on the number of supported formats, and print
+       the indices as type specific helper macros.
+
+       * math/libm-test.inc: Remove comment about CHOOSE.
+       (ulp_data): Generate the type in libm-test-ulps.h.
+       (ULP_IDX): New macro.
+       (find_ulps): Update usage of max_ulp.
+
+       * math/test-double-vlen2.h (CHOOSE): Remove.
+       * math/test-double-vlen4.h (CHOOSE): Likewise.
+       * math/test-double-vlen8.h (CHOOSE): Likewise.
+       * math/test-float.c (CHOOSE): Likewise.
+       * math/test-float-finite.c (CHOOSE): Likewise.
+       * math/test-double.c (CHOOSE): Likewise.
+       * math/test-double-finite.c (CHOOSE): Likewise.
+       * math/test-idouble.c (CHOOSE): Likewise.
+       * math/test-ifloat.c (CHOOSE): Likewise.
+       * math/test-ildoubl.c (CHOOSE): Likewise.
+       * math/test-ldouble-finite.c (CHOOSE): Likewise.
+       * math/test-ldouble.c (CHOOSE): Likewise.
+
+       * math/test-float.h (TEST_FLOAT): Remove.
+       * math/test-double.h (TEST_DOUBLE): Likewise.
+       * math/test-ldouble.h (TEST_LDOUBLE): Likewise.
+
 2016-06-08  Paul E. Murphy  <murphyp@linux.vnet.ibm.com>
 
        * math/gen-libm-test.pl: (apply_lit): New subroutine.
index 9d0fc006babdcef6ca3646d7d9b0a442e4848df1..9cdcc4343a9b0aa7814524da68225b550a903c15 100755 (executable)
@@ -39,7 +39,7 @@ use strict;
 
 use vars qw ($input $output $auto_input);
 use vars qw (%results);
-use vars qw (%beautify @all_floats);
+use vars qw (%beautify @all_floats %all_floats_pfx);
 use vars qw ($output_dir $ulps_file $srcdir);
 use vars qw (%auto_tests);
 
@@ -47,6 +47,13 @@ use vars qw (%auto_tests);
 @all_floats = ('double', 'float', 'idouble',
               'ifloat', 'ildouble', 'ldouble');
 
+# all_floats_pfx maps C types to their C like prefix for macros.
+%all_floats_pfx =
+  ( "double" => "DBL",
+    "ldouble" => "LDBL",
+    "float" => "FLT",
+  );
+
 %beautify =
   ( "minus_zero" => "-0",
     "plus_zero" => "+0",
@@ -586,7 +593,14 @@ sub generate_testfile {
 # Parse ulps file
 sub parse_ulps {
   my ($file) = @_;
-  my ($test, $type, $float, $eps);
+  my ($test, $type, $float, $eps, $float_regex);
+
+  # Build a basic regex to match type entries in the
+  # generated ULPS file.
+  foreach my $ftype (@all_floats) {
+    $float_regex .= "|" . $ftype;
+  }
+  $float_regex = "^" . substr ($float_regex, 1) . ":";
 
   # $type has the following values:
   # "normal": No complex variable
@@ -611,7 +625,7 @@ sub parse_ulps {
       ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
       next;
     }
-    if (/^i?(float|double|ldouble):/) {
+    if (/$float_regex/) {
       ($float, $eps) = split /\s*:\s*/,$_,2;
 
       if ($eps eq "0") {
@@ -695,16 +709,13 @@ sub get_ulps {
 sub get_all_ulps_for_test {
   my ($test, $type) = @_;
   my ($ldouble, $double, $float, $ildouble, $idouble, $ifloat);
+  my ($ulps_str);
 
   if (exists $results{$test}{'has_ulps'}) {
-    # XXX use all_floats (change order!)
-    $ldouble = &get_ulps ($test, $type, "ldouble");
-    $double = &get_ulps ($test, $type, "double");
-    $float = &get_ulps ($test, $type, "float");
-    $ildouble = &get_ulps ($test, $type, "ildouble");
-    $idouble = &get_ulps ($test, $type, "idouble");
-    $ifloat = &get_ulps ($test, $type, "ifloat");
-    return "CHOOSE ($ldouble, $double, $float, $ildouble, $idouble, $ifloat)";
+    foreach $float (@all_floats) {
+      $ulps_str .= &get_ulps ($test, $type, $float) . ", ";
+    }
+    return "{" . substr ($ulps_str, 0, -2) . "}";
   } else {
     die "get_all_ulps_for_test called for \"$test\" with no ulps\n";
   }
@@ -722,6 +733,22 @@ sub output_ulps {
   print ULP "   from $ulps_filename with gen-libm-test.pl.\n";
   print ULP "   Don't change it - change instead the master files.  */\n\n";
 
+  print ULP "struct ulp_data\n";
+  print ULP "{\n";
+  print ULP "  const char *name;\n";
+  print ULP "  FLOAT max_ulp[" . @all_floats . "];\n";
+  print ULP "};\n\n";
+
+  for ($i = 0; $i <= $#all_floats; $i++) {
+    $type = $all_floats[$i];
+    print ULP "#define ULP_";
+    if ($type =~ /^i/) {
+      print ULP "I_";
+      $type = substr $type, 1;
+    }
+    print ULP "$all_floats_pfx{$type} $i\n";
+  }
+
   foreach $fct (keys %results) {
     $type = $results{$fct}{'type'};
     if ($type eq 'normal') {
index 3218cefd7aac1cd058573ced1db93c5571eec890..ef869a7979feabc9fcf740c3fd5e58fdee9132c6 100644 (file)
@@ -26,7 +26,6 @@
    name with correct suffix (e.g. cosl or cosf)
    FLOAT:         floating point type to test
    - TEST_MSG:    informal message to be displayed
-   CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat):
    chooses one of the parameters as delta for testing
    equality
    PRINTF_EXPR    Floating point conversion specification to print a variable
 #include <math-tests.h>
 #include <math-tests-arch.h>
 
-/* Structure for ulp data for a function, or the real or imaginary
-   part of a function.  */
-struct ulp_data
-{
-  const char *name;
-  FLOAT max_ulp;
-};
-
 /* This header defines func_ulps, func_real_ulps and func_imag_ulps
    arrays.  */
 #include "libm-test-ulps.h"
@@ -202,8 +193,10 @@ struct ulp_data
 #define FSTR_MAX (128)
 
 #if TEST_INLINE
+# define ULP_IDX __CONCATX (ULP_I_, PREFIX)
 # define QTYPE_STR "i" TYPE_STR
 #else
+# define ULP_IDX __CONCATX (ULP_, PREFIX)
 # define QTYPE_STR TYPE_STR
 #endif
 
@@ -369,7 +362,7 @@ find_ulps (const char *name, const struct ulp_data *data, size_t nmemb)
   if (entry == NULL)
     return 0;
   else
-    return entry->max_ulp;
+    return entry->max_ulp[ULP_IDX];
 }
 
 static void
index e7fa2a9dd48790446f9632226d7a83a5ffb9fe32..7f107aa649932905109edcbea95045ccc5a6cffa 100644 (file)
@@ -21,6 +21,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing double (finite-math-only)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
 
 #include "libm-test.c"
index 8a1d0683ebe299c1d665511954c190fa21827be1..45351cb2543d79723229036d84b700caade8ad09 100644 (file)
@@ -21,7 +21,6 @@
 #include "test-math-vector.h"
 
 #define TEST_MSG "testing double vector math (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
 
 #define EXCEPTION_TESTS_double 0
 #define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST)
index 40ab58c490281a3f688eb007e2bc99a9d6ef76b7..7078893f5347c1b401c7d5c6880f0d4f93c4fe3f 100644 (file)
@@ -21,7 +21,6 @@
 #include "test-math-vector.h"
 
 #define TEST_MSG "testing double vector math (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
 
 #define EXCEPTION_TESTS_double 0
 #define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST)
index dddb52c00815856e947e5b1c7153b4997c30b1f8..57168c58cd3bd69089a17a83e8b49d00393c06eb 100644 (file)
@@ -21,7 +21,6 @@
 #include "test-math-vector.h"
 
 #define TEST_MSG "testing double vector math (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
 
 #define EXCEPTION_TESTS_double 0
 #define ROUNDING_TESTS_double(MODE) ((MODE) == FE_TONEAREST)
index 2647f66a8c561681440b8792bd4271c252c459f5..3f84f4043325bb9073dfa69630b07d759a422484 100644 (file)
@@ -23,6 +23,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing double (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
 
 #include "libm-test.c"
index 3667883efcb40f18ec36ed582ef000f258c45c5f..b9e8cd840c336aa7516800cda32cc80b4760f115 100644 (file)
@@ -21,7 +21,6 @@
 #define PRINTF_EXPR "e"
 #define PRINTF_XEXPR "a"
 #define PRINTF_NEXPR "f"
-#define TEST_DOUBLE 1
 #define BUILD_COMPLEX(real, imag) (CMPLX ((real), (imag)))
 #define PREFIX DBL
 #define LIT(x) (x)
index bd25a7bc31e667d80f3e4de0333f43e40103ee25..3f5fe1952f3cd4b5a1c74d018b6f48035d9c814e 100644 (file)
@@ -21,6 +21,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing float (finite-math-only)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
 
 #include "libm-test.c"
index a2db3a5c4d07676bd317bbe9da11ef376d2f77e8..d31336a799c81d0a39a5d79d25c5d4cae7750ece 100644 (file)
@@ -21,7 +21,6 @@
 #include "test-math-vector.h"
 
 #define TEST_MSG "testing float vector math (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
 
 #define EXCEPTION_TESTS_float 0
 #define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST)
index 164749d85cc378a18605efc200f328dbe91126c4..5a88fb857daf6b69caa2317abe1f8794a159c96b 100644 (file)
@@ -21,7 +21,6 @@
 #include "test-math-vector.h"
 
 #define TEST_MSG "testing float vector math (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
 
 #define EXCEPTION_TESTS_float 0
 #define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST)
index ce32df200a66dc8bc7dbb7eb71d14d641757c45e..d1e5e6e3d0cb3c9875347a6869600d88e0ac47a2 100644 (file)
@@ -21,7 +21,6 @@
 #include "test-math-vector.h"
 
 #define TEST_MSG "testing float vector math (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
 
 #define EXCEPTION_TESTS_float 0
 #define ROUNDING_TESTS_float(MODE) ((MODE) == FE_TONEAREST)
index 153b9ad4dca73fe5c85d46213f59f83f565a1680..6be57bb8a34bf5c7e2c7ef4e65940e665ac25e4e 100644 (file)
@@ -23,6 +23,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing float (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
 
 #include "libm-test.c"
index 4f9149f89c9611dae6eea38e4849e67dba9c0622..e783c094c9b88b1c7cca2270e9d8ccad40b7decb 100644 (file)
@@ -21,7 +21,6 @@
 #define PRINTF_EXPR "e"
 #define PRINTF_XEXPR "a"
 #define PRINTF_NEXPR "f"
-#define TEST_FLOAT 1
 #define BUILD_COMPLEX(real, imag) (CMPLXF ((real), (imag)))
 #define PREFIX FLT
 #define TYPE_STR "float"
index fc1e8f89c12a9b45a75288adf397fe6d3430c33a..10a3685b5e38bf9c8d9b34ac9a0b151ea625613d 100644 (file)
@@ -21,6 +21,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing double (inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinedouble
 
 #include "libm-test.c"
index 72c53ad64331fd0c9dd746f4ad8ba7ffdb1c35bf..88bb5b844f7321f24e18eff885e137f39cdcc706 100644 (file)
@@ -21,6 +21,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing float (inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinefloat
 
 #include "libm-test.c"
index 08317ed621efd492fea33996bd0361bf574dc0ef..dc0efaa879130d684d6a60701d7ba906bc07d901 100644 (file)
@@ -21,6 +21,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing long double (inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cinlinelongdouble
 
 #include "libm-test.c"
index 4c09778ec18442aada92ab2a437ef217cfb061bf..8ac2d335c5bf1cee28ed15a16754a889a4450f20 100644 (file)
@@ -21,6 +21,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing long double (finite-math-only)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Clongdouble
 
 #include "libm-test.c"
index 944f6ddfe69c6b41ca50607b7d9328f4ca485639..a705fa4aea08e330ccf527c657ea8c11e063861f 100644 (file)
@@ -23,6 +23,5 @@
 #include "test-math-scalar.h"
 
 #define TEST_MSG "testing long double (without inline functions)\n"
-#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Clongdouble
 
 #include "libm-test.c"
index f3a8d8da9f462d3daac8c80239504318b070fb0c..b87771175803fcc743a1a07c12c13d92a43f9012 100644 (file)
@@ -21,7 +21,6 @@
 #define PRINTF_EXPR "Le"
 #define PRINTF_XEXPR "La"
 #define PRINTF_NEXPR "Lf"
-#define TEST_LDOUBLE 1
 #define BUILD_COMPLEX(real, imag) (CMPLXL ((real), (imag)))
 #define PREFIX LDBL
 #define TYPE_STR "ldouble"