diff options
author | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-06-08 14:37:15 -0500 |
---|---|---|
committer | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-06-08 14:37:15 -0500 |
commit | 9c665e085f092d2fd1c0c159532d94191b8e2aec (patch) | |
tree | c1603caf0e6366d2e2532c2ebd76c76c5506a890 /math/gen-libm-test.pl | |
parent | 89385134849a9a4aa66f5b2ebaedaad7d63a11db (diff) | |
download | glibc-9c665e085f092d2fd1c0c159532d94191b8e2aec.tar.gz glibc-9c665e085f092d2fd1c0c159532d94191b8e2aec.tar.xz glibc-9c665e085f092d2fd1c0c159532d94191b8e2aec.zip |
Remove CHOOSE() macro from libm-tests.inc
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.
Diffstat (limited to 'math/gen-libm-test.pl')
-rwxr-xr-x | math/gen-libm-test.pl | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl index 9d0fc006ba..9cdcc4343a 100755 --- a/math/gen-libm-test.pl +++ b/math/gen-libm-test.pl @@ -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') { |