diff options
author | Joseph Myers <joseph@codesourcery.com> | 2014-03-06 14:11:19 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2014-03-06 14:11:19 +0000 |
commit | aa97dee16e5299bf2b8f7b2d67215361c7c904e2 (patch) | |
tree | 99e45c15390bfa53325b8e8400d1ccfe8c253b40 /math/gen-libm-test.pl | |
parent | 2f0a0f44274808faa6bb55dd28b9ddbda6380f2a (diff) | |
download | glibc-aa97dee16e5299bf2b8f7b2d67215361c7c904e2.tar.gz |
Adjust how gen-auto-libm-tests handles before-rounding/after-rounding cases.
This patch changes gen-auto-libm-tests so that, when generating test
results that depend on whether the architecture has before-rounding or
after-rounding tininess detection, the :before-rounding or
:after-rounding conditions go on the exception / errno flags
generated, rather than generating two separate lines in
auto-libm-test-out for e.g. flt-32:before-rounding and
flt-32:after-rounding.
The rationale for this is as follows. It would be desirable for
testing a libm function in all rounding modes to require just one
function and array in libm-test.inc, not four (or five), with the
array of test data including expected results for all rounding modes
rather than separate arrays for each rounding mode that also need to
repeat all the test inputs. For gen-libm-test.pl to generate data for
such an array from auto-libm-test-out, it would be helpful if each
(format, test input) pair has exactly four lines in
auto-libm-test-out, one for each rounding mode, rather than some
rounding modes having just one line and some having two because the
exceptions depend on tininess detection.
Tested x86_64 and x86.
* math/gen-auto-libm-tests.c: Update comment on output format.
(output_for_one_input_case): Generate before-rounding and
after-rounding information as conditions on output flags not
floating-point format.
* math/auto-libm-test-out: Regenerated.
* math/gen-libm-test.pl (cond_value): New function.
(or_cond_value): Use cond_value.
(generate_testfile): Handle conditional exceptions.
Diffstat (limited to 'math/gen-libm-test.pl')
-rwxr-xr-x | math/gen-libm-test.pl | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl index 919f0f2306..a5abda2fb0 100755 --- a/math/gen-libm-test.pl +++ b/math/gen-libm-test.pl @@ -326,19 +326,25 @@ sub or_value { } } -# Return text to OR a conditional expression between two values into -# an accumulated flags string. -sub or_cond_value { +# Return a conditional expression between two values. +sub cond_value { my ($cond, $if, $else) = @_; if ($cond eq "1") { - return or_value ($if); + return $if; } elsif ($cond eq "0") { - return or_value ($else); + return $else; } else { - return or_value ("($cond ? $if : $else)"); + return "($cond ? $if : $else)"; } } +# Return text to OR a conditional expression between two values into +# an accumulated flags string. +sub or_cond_value { + my ($cond, $if, $else) = @_; + return or_value (cond_value ($cond, $if, $else)); +} + # Generate libm-test.c sub generate_testfile { my ($input, $output) = @_; @@ -392,7 +398,7 @@ sub generate_testfile { my (@exc_list) = qw(divbyzero inexact invalid overflow underflow); my ($exc); foreach $exc (@exc_list) { - my ($exc_expected, $exc_ok, $no_exc); + my ($exc_expected, $exc_ok, $no_exc, $exc_cond, $exc_ok_cond); $exc_expected = "\U$exc\E_EXCEPTION"; $exc_ok = "\U$exc\E_EXCEPTION_OK"; $no_exc = "0"; @@ -401,23 +407,20 @@ sub generate_testfile { $no_exc = "NO_INEXACT_EXCEPTION"; } if (defined ($flag_cond{$exc})) { - if ($flag_cond{$exc} ne "1") { - die ("unexpected condition for $exc\n"); - } - if (defined ($flag_cond{"$exc-ok"})) { - $flags_conv .= or_cond_value ($flag_cond{"$exc-ok"}, - $exc_ok, $exc_expected); - } else { - $flags_conv .= or_value ($exc_expected); - } + $exc_cond = $flag_cond{$exc}; } else { - if (defined ($flag_cond{"$exc-ok"})) { - $flags_conv .= or_cond_value ($flag_cond{"$exc-ok"}, - $exc_ok, $no_exc); - } else { - $flags_conv .= or_value ($no_exc); - } + $exc_cond = "0"; + } + if (defined ($flag_cond{"$exc-ok"})) { + $exc_ok_cond = $flag_cond{"$exc-ok"}; + } else { + $exc_ok_cond = "0"; } + $flags_conv .= or_cond_value ($exc_cond, + cond_value ($exc_ok_cond, + $exc_ok, $exc_expected), + cond_value ($exc_ok_cond, + $exc_ok, $no_exc)); } my ($errno_expected, $errno_unknown_cond); if (defined ($flag_cond{"errno-edom"})) { |