1 # Script used in producing headers of assembly constants from C expressions.
2 # The input to this script looks like:
6 # The output of this script is C code to be run through gcc -S and then
7 # massaged to extract the integer constant values of the given C expressions.
8 # A line giving just a name implies an expression consisting of just that name.
12 # cpp directives go straight through.
17 print "\n#include <stdio.h>";
18 print "\nstatic int do_test (void)\n{\n int bad = 0, good = 0;\n";
19 print "#define TEST(name, source, expr) \\\n" \
20 " if (asconst_##name != (expr)) { ++bad;" \
21 " fprintf (stderr, \"%s: %s is %ld but %s is %ld\\n\"," \
22 " source, #name, (long int) asconst_##name, #expr, (long int) (expr));" \
26 print "void dummy(void) {";
33 NF ==
1 { sub(/^.
*$
/, "& &"); }
37 sub(/^
[^
]+[ ]+/, "");
39 print " TEST (" name
", \"" FILENAME ":" FNR "\", " $
0 ")";
41 printf "asm (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" ((long) %s));\n",
47 print " printf (\"%d errors in %d tests\\n\", bad, good + bad);"
48 print " return bad != 0 || good == 0;\n}\n";
49 print "#define TEST_FUNCTION do_test ()";
51 else if (started
) print "}";