From patchwork Fri May 20 21:37:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 12432 Received: (qmail 116634 invoked by alias); 20 May 2016 21:37:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116581 invoked by uid 89); 20 May 2016 21:37:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=2527, 1526, 2996 X-HELO: e32.co.us.ibm.com X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: murphyp@linux.vnet.ibm.com X-IBM-RcptTo: libc-alpha@sourceware.org From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCHv2 11/14] Apply LIT(x) to floating point literals in libm-test.c Date: Fri, 20 May 2016 16:37:20 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16052021-0005-0000-0000-00007557E2A3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused With the exception of the second argument of nexttoward, any suffixes should be stripped from the test input, and the macro LIT(x) should be applied to use the correct suffix for the type being tested. This applies post-processing to all of the test inputs through gen-libm-test.pl to strip literal suffixes and apply the LIT(x) macro, with one exception stated above. This seems a bit cleaner than tossing the macro onto everything albeit slightly more obfuscated. * math/gen-libm-test.pl: (apply_lit): New subroutine. (parse_args): Strip C suffix from floating point literals and wrap them with LIT(). --- math/gen-libm-test.pl | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl index c8790e1..40839e0 100755 --- a/math/gen-libm-test.pl +++ b/math/gen-libm-test.pl @@ -152,6 +152,30 @@ sub show_exceptions { } } +# Apply the LIT(x) macro to any floating point constants. +sub apply_lit { + my ($lit) = @_; + my $lletter = substr $lit, -1; + my $exp_re = "([+-])?[[:digit:]]+"; + + # Don't wrap something that does not look like a: + # hexadecimal FP value, + # base 10 integer raised to a power, + # something with a decimal point. + if ($lit !~ /([+-])?0x[[:xdigit:]\.]+[pP]$exp_re/ + and $lit !~ /[[:digit:]]+[eE]$exp_re/ + and $lit !~ /[[:digit:]]*\.[[:digit:]]*([eE]$exp_re)?/ + ){ + return $lit; + } + + # Strip any suffixes from the constant + if ($lletter =~ /L|l|f|F/) { + chop $lit; + } + return "LIT ($lit)"; +} + # Parse the arguments to TEST_x_y sub parse_args { my ($file, $descr, $args) = @_; @@ -242,7 +266,11 @@ sub parse_args { for ($i=0; $i <= $#descr; $i++) { # FLOAT, int, long int, long long int if ($descr[$i] =~ /f|i|l|L/) { - $cline .= ", $args[$current_arg]"; + if ($descr[$i] eq "f" and not ($args[0] eq "nexttoward" and $current_arg == 2)) { + $cline .= ", " . &apply_lit ($args[$current_arg]); + } else { + $cline .= ", $args[$current_arg]"; + } $current_arg++; next; } @@ -252,7 +280,8 @@ sub parse_args { } # complex if ($descr[$i] eq 'c') { - $cline .= ", $args[$current_arg], $args[$current_arg+1]"; + $cline .= ", " . &apply_lit ($args[$current_arg]); + $cline .= ", " . &apply_lit ($args[$current_arg+1]); $current_arg += 2; next; } @@ -282,6 +311,9 @@ sub parse_args { } else { $ignore_result_all = 0; } + if ($_ eq "f") { + $result = apply_lit ($result) + } $cline_res .= ", $result"; $current_arg++; } elsif ($_ eq 'c') { @@ -299,6 +331,8 @@ sub parse_args { } else { $ignore_result_all = 0; } + $result1 = apply_lit ($result1); + $result2 = apply_lit ($result2); $cline_res .= ", $result1, $result2"; $current_arg += 2; } elsif ($_ eq '1') { @@ -327,6 +361,8 @@ sub parse_args { my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0); if (!$run_extra) { $extra_expected = "0"; + } else { + $extra_expected = apply_lit ($extra_expected); } $cline_res .= ", $run_extra, $extra_expected"; }