From d4cf1331007743c21e4f03603add48a107a6857d Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Fri, 15 Jul 2016 10:57:07 -0500 Subject: Improve gen-libm-test.pl LIT() application When bootstrapping float128, this exposed a number of areas where the L suffix is incorrectly applied to simple expressions when it should be applied to each constant in the expression. In order to stave off more macros in libm-test.inc, apply_lit is made slightly more intelligent. It will now split expressions based on space characters, and attempt to apply LIT() to each token. Having done this, there are numerous spacing issues within libm-test.inc which have been fixed. The above is problematic when the L real suffix is not the most expressive modifier, and the compiler complains (i.e ppc64) or silently truncates a value (i.e ppc64). --- math/gen-libm-test.pl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'math/gen-libm-test.pl') diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl index aa66e76..577964c 100755 --- a/math/gen-libm-test.pl +++ b/math/gen-libm-test.pl @@ -163,7 +163,7 @@ sub show_exceptions { # Apply the LIT(x) macro to a literal floating point constant # and strip any existing suffix. -sub apply_lit { +sub _apply_lit { my ($lit) = @_; my $exp_re = "([+-])?[[:digit:]]+"; # Don't wrap something that does not look like a: @@ -180,6 +180,21 @@ sub apply_lit { return "LIT (${lit})"; } +# Apply LIT macro to individual tokens within an expression. +# +# This function assumes the C expression follows GNU coding +# standards. Specifically, a space separates each lexical +# token. Otherwise, this post-processing may apply LIT +# incorrectly, or around an entire expression. +sub apply_lit { + my ($lit) = @_; + my @toks = split (/ /, $lit); + foreach (@toks) { + $_ = _apply_lit ($_); + } + return join (' ', @toks); +} + # Parse the arguments to TEST_x_y sub parse_args { my ($file, $descr, $args) = @_; -- cgit v1.1