2017-02-06 Joseph Myers <joseph@codesourcery.com>
* math/gen-auto-libm-tests.c: Update comment about use of program.
(generate_output): Add argument FUNCTION.
(main): Require extra argument. Pass function name to
generate_output.
* math/Makefile (generated): Add auto-libm-test-out.
(libm-test-funcs-auto): New variable.
(auto-libm-test-out-files): New variable.
($(objpfx)libm-test.c): Depend on $(auto-libm-test-out-files).
Concatenate those files to form $(objpfx)auto-libm-test-out and
use it as input to gen-libm-test.pl.
* math/README.libm-test: Update.
* math/auto-libm-test-out: Remove.
* math/auto-libm-test-out-acos: New generated file.
* math/auto-libm-test-out-acosh: Likewise.
* math/auto-libm-test-out-asin: Likewise.
* math/auto-libm-test-out-asinh: Likewise.
* math/auto-libm-test-out-atan: Likewise.
* math/auto-libm-test-out-atan2: Likewise.
* math/auto-libm-test-out-atanh: Likewise.
* math/auto-libm-test-out-cabs: Likewise.
* math/auto-libm-test-out-carg: Likewise.
* math/auto-libm-test-out-cbrt: Likewise.
* math/auto-libm-test-out-ccos: Likewise.
* math/auto-libm-test-out-ccosh: Likewise.
* math/auto-libm-test-out-cexp: Likewise.
* math/auto-libm-test-out-clog: Likewise.
* math/auto-libm-test-out-clog10: Likewise.
* math/auto-libm-test-out-cos: Likewise.
* math/auto-libm-test-out-cosh: Likewise.
* math/auto-libm-test-out-cpow: Likewise.
* math/auto-libm-test-out-csin: Likewise.
* math/auto-libm-test-out-csinh: Likewise.
* math/auto-libm-test-out-csqrt: Likewise.
* math/auto-libm-test-out-ctan: Likewise.
* math/auto-libm-test-out-ctanh: Likewise.
* math/auto-libm-test-out-erf: Likewise.
* math/auto-libm-test-out-erfc: Likewise.
* math/auto-libm-test-out-exp: Likewise.
* math/auto-libm-test-out-exp10: Likewise.
* math/auto-libm-test-out-exp2: Likewise.
* math/auto-libm-test-out-expm1: Likewise.
* math/auto-libm-test-out-fma: Likewise.
* math/auto-libm-test-out-hypot: Likewise.
* math/auto-libm-test-out-j0: Likewise.
* math/auto-libm-test-out-j1: Likewise.
* math/auto-libm-test-out-jn: Likewise.
* math/auto-libm-test-out-lgamma: Likewise.
* math/auto-libm-test-out-log: Likewise.
* math/auto-libm-test-out-log10: Likewise.
* math/auto-libm-test-out-log1p: Likewise.
* math/auto-libm-test-out-log2: Likewise.
* math/auto-libm-test-out-pow: Likewise.
* math/auto-libm-test-out-sin: Likewise.
* math/auto-libm-test-out-sincos: Likewise.
* math/auto-libm-test-out-sinh: Likewise.
* math/auto-libm-test-out-sqrt: Likewise.
* math/auto-libm-test-out-tan: Likewise.
* math/auto-libm-test-out-tanh: Likewise.
* math/auto-libm-test-out-tgamma: Likewise.
* math/auto-libm-test-out-y0: Likewise.
* math/auto-libm-test-out-y1: Likewise.
* math/auto-libm-test-out-yn: Likewise.
@@ -208,7 +208,7 @@ libm-vec-test-wrappers = $(addsuffix -wrappers, $(libm-vec-tests))
test-extras += $(libm-vec-test-wrappers)
extra-test-objs += $(addsuffix .o, $(libm-vec-test-wrappers))
libm-tests-generated = libm-test-ulps.h libm-have-vector-test.h libm-test.c
-generated += $(libm-tests-generated)
+generated += $(libm-tests-generated) auto-libm-test-out
ulps-file = $(firstword $(wildcard $(sysdirs:%=%/libm-test-ulps)))
@@ -216,9 +216,18 @@ $(objpfx)libm-test-ulps.h: $(ulps-file) gen-libm-test.pl
$(make-target-directory)
$(PERL) gen-libm-test.pl -u $< -H $@
-$(objpfx)libm-test.c: libm-test.inc gen-libm-test.pl auto-libm-test-out
+libm-test-funcs-auto = acos acosh asin asinh atan atan2 atanh cabs carg cbrt \
+ ccos ccosh cexp clog clog10 cos cosh cpow csin csinh \
+ csqrt ctan ctanh erf erfc exp exp10 exp2 expm1 fma \
+ hypot j0 j1 jn lgamma log log10 log1p log2 pow sin \
+ sincos sinh sqrt tan tanh tgamma y0 y1 yn
+auto-libm-test-out-files = $(addprefix auto-libm-test-out-,\
+ $(libm-test-funcs-auto))
+
+$(objpfx)libm-test.c: libm-test.inc gen-libm-test.pl $(auto-libm-test-out-files)
$(make-target-directory)
- $(PERL) gen-libm-test.pl -c $< -a auto-libm-test-out -C $@
+ cat $(auto-libm-test-out-files) > $(objpfx)auto-libm-test-out
+ $(PERL) gen-libm-test.pl -c $< -a $(objpfx)auto-libm-test-out -C $@
$(objpfx)libm-have-vector-test.h: libm-test.inc gen-libm-have-vector-test.sh
$(make-target-directory)
@@ -24,7 +24,7 @@ Files that are part of libm-test
The main file is "libm-test.inc". It is independent of the target
platform and the specific real floating type and format and contains
placeholder test "templates" for math functions defined in libm.
-The file, along with a generated file named "auto-libm-test-out",
+The file, along with generated files named "auto-libm-test-out-<func>",
is preprocessed by the Perl script "gen-libm-test.pl" to expand
the templates and produce a set of test cases for each math function
that are specific to the target platform but still independent of
@@ -55,11 +55,12 @@ maximum difference expressed as Units of Least Precision (ULP) the
actual result of the function may deviate from the expected result
before it's considered incorrect.
-The "auto-libm-test-out" file contains sets of test cases to exercise,
-the conditions under which to exercise each, and the expected results.
-The file is generated by the "gen-auto-libm-tests" program from the
-"auto-libm-test-in" file. See the comments in gen-auto-libm-tests.c
-for details about the content and format of the -in and -out files.
+The "auto-libm-test-out-<func>" files contain sets of test cases to
+exercise, the conditions under which to exercise each, and the
+expected results. The files are generated by the
+"gen-auto-libm-tests" program from the "auto-libm-test-in" file. See
+the comments in gen-auto-libm-tests.c for details about the content
+and format of the -in and -out files.
How can I generate "libm-test-ulps"?
====================================
@@ -23,7 +23,7 @@
(use of current MPC and MPFR versions recommended) and run it as:
- gen-auto-libm-tests auto-libm-test-in auto-libm-test-out
+ gen-auto-libm-tests auto-libm-test-in <func> auto-libm-test-out-<func>
The input file auto-libm-test-in contains three kinds of lines:
@@ -98,7 +98,7 @@
accompanied by a comment referring to an open bug in glibc
Bugzilla.
- The output file auto-libm-test-out contains the test lines from
+ The output file auto-libm-test-out-<func> contains the test lines from
auto-libm-test-in, and, after the line for a given test, some
number of output test lines. An output test line is of the form "=
function rounding-mode format input1 input2 ... : output1 output2
@@ -2158,10 +2158,10 @@ output_for_one_input_case (FILE *fp, const char *filename, test_function *tf,
generic_value_free (&generic_outputs[i]);
}
-/* Generate test output data to FILENAME. */
+/* Generate test output data for FUNCTION to FILENAME. */
static void
-generate_output (const char *filename)
+generate_output (const char *function, const char *filename)
{
FILE *fp = fopen (filename, "w");
if (fp == NULL)
@@ -2169,6 +2169,8 @@ generate_output (const char *filename)
for (size_t i = 0; i < ARRAY_SIZE (test_functions); i++)
{
test_function *tf = &test_functions[i];
+ if (strcmp (tf->name, function) != 0)
+ continue;
for (size_t j = 0; j < tf->num_tests; j++)
{
input_test *it = &tf->tests[j];
@@ -2185,12 +2187,14 @@ generate_output (const char *filename)
int
main (int argc, char **argv)
{
- if (argc != 3)
- error (EXIT_FAILURE, 0, "usage: gen-auto-libm-tests <input> <output>");
+ if (argc != 4)
+ error (EXIT_FAILURE, 0,
+ "usage: gen-auto-libm-tests <input> <func> <output>");
const char *input_filename = argv[1];
- const char *output_filename = argv[2];
+ const char *function = argv[2];
+ const char *output_filename = argv[3];
init_fp_formats ();
read_input (input_filename);
- generate_output (output_filename);
+ generate_output (function, output_filename);
exit (EXIT_SUCCESS);
}