diff --git a/js/src/lirasm/LInsClasses.tbl b/js/src/lirasm/LInsClasses.tbl index 2a0a80de3de..732e87d5fe6 100644 --- a/js/src/lirasm/LInsClasses.tbl +++ b/js/src/lirasm/LInsClasses.tbl @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=0 ft=C: + * vim: set ts=8 sw=4 et tw=0 ft=c: * * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 diff --git a/js/src/lirasm/lirasm.cpp b/js/src/lirasm/lirasm.cpp index 186c7b19b52..cd405b18fad 100644 --- a/js/src/lirasm/lirasm.cpp +++ b/js/src/lirasm/lirasm.cpp @@ -2263,7 +2263,13 @@ processCmdLine(int argc, char **argv, CmdLineOptions& opts) avmplus::AvmCore::config.i386_use_cmov = avmplus::AvmCore::config.i386_sse2 = i386_sse; avmplus::AvmCore::config.i386_fixed_esp = true; #elif defined NANOJIT_ARM - // Note that we don't check for sensible configurations here! + // Warn about untested configurations. + if ( ((arm_arch == 5) && (arm_vfp)) || ((arm_arch >= 6) && (!arm_vfp)) ) { + char const * vfp_string = (arm_vfp) ? ("VFP") : ("no VFP"); + cerr << "Warning: This configuration (ARMv" << arm_arch << ", " << vfp_string << ") " << + "is not regularly tested." << endl; + } + avmplus::AvmCore::config.arm_arch = arm_arch; avmplus::AvmCore::config.arm_vfp = arm_vfp; avmplus::AvmCore::config.soft_float = !arm_vfp; diff --git a/js/src/lirasm/testlirc.sh b/js/src/lirasm/testlirc.sh index 25cff6a12c2..e6a608f6cdf 100755 --- a/js/src/lirasm/testlirc.sh +++ b/js/src/lirasm/testlirc.sh @@ -6,34 +6,75 @@ LIRASM=$1 TESTS_DIR=`dirname "$0"`/tests -for infile in "$TESTS_DIR"/*.in -do - outfile=`echo $infile | sed 's/\.in/\.out/'` - if [ ! -e "$outfile" ] +function runtest { + local infile=$1 + local options=${2-} + + # Catch a request for the random tests. + if [[ $infile == --random* ]] + then + local outfile=$TESTS_DIR/random.out + else + local outfile=`echo $infile | sed 's/\.in/\.out/'` + fi + + if [[ ! -e "$outfile" ]] then echo "$0: error: no out file $outfile" exit 1 fi - # Treat "random.in" and "random-opt.in" specially. - if [ `basename $infile` = "random.in" ] + if $LIRASM $options --execute $infile | tr -d '\r' > testoutput.txt && cmp -s testoutput.txt $outfile then - infile="--random 1000000" - elif [ `basename $infile` = "random-opt.in" ] - then - infile="--random 1000000 --optimize" - fi - - if $LIRASM --execute $infile | tr -d '\r' > testoutput.txt && cmp -s testoutput.txt $outfile - then - echo "TEST-PASS | lirasm | lirasm --execute $infile" + echo "TEST-PASS | lirasm | lirasm $options --execute $infile" else - echo "TEST-UNEXPECTED-FAIL | lirasm | lirasm --execute $infile" + echo "TEST-UNEXPECTED-FAIL | lirasm | lirasm $options --execute $infile" echo "expected output" cat $outfile echo "actual output" cat testoutput.txt fi +} + +# Tests common to all supported back-ends. +for infile in "$TESTS_DIR"/*.in +do + runtest $infile done +runtest "--random 1000000" +runtest "--random 1000000 --optimize" + +# ---- Platform-specific tests and configurations. ---- + +# ARM +if [[ $(uname -m) == arm* ]] +then + for infile in "$TESTS_DIR"/*.in + do + # Run standard tests, but set code generation for older architectures. + # It may also be beneficial to test ARMv6 and ARMv7 with --novfp, but such + # a platform seems so unlikely that it probably isn't worthwhile. It's also + # unlikely that it's worth testing ARMv5 with VFP. + runtest $infile "--arch 6" + runtest $infile "--arch 5 --novfp" + done + + # Run specific soft-float tests, but only for ARMv5 without VFP. + # NOTE: It looks like MIPS ought to be able to run these tests, but I can't + # test this and _not_ running them seems like the safest option. + for infile in "$TESTS_DIR"/softfloat/*.in + do + runtest $infile "--arch 5 --novfp" + done + + # Run reduced random tests for these targets. (The default ARMv7 target + # still runs the long tests.) + runtest "--random 10000 --arch 6" + runtest "--random 10000 --arch 5 --novfp" + runtest "--random 10000 --optimize --arch 6" + runtest "--random 10000 --optimize --arch 5 --novfp" +fi + rm testoutput.txt + diff --git a/js/src/lirasm/tests/random-opt.in b/js/src/lirasm/tests/random-opt.in deleted file mode 100644 index 425c12166f1..00000000000 --- a/js/src/lirasm/tests/random-opt.in +++ /dev/null @@ -1 +0,0 @@ -# dummy file, contents aren't used diff --git a/js/src/lirasm/tests/random.in b/js/src/lirasm/tests/random.in deleted file mode 100644 index 425c12166f1..00000000000 --- a/js/src/lirasm/tests/random.in +++ /dev/null @@ -1 +0,0 @@ -# dummy file, contents aren't used diff --git a/js/src/lirasm/tests/softfloat/dhi2i.in b/js/src/lirasm/tests/softfloat/dhi2i.in new file mode 100644 index 00000000000..89b7d55daec --- /dev/null +++ b/js/src/lirasm/tests/softfloat/dhi2i.in @@ -0,0 +1,4 @@ +; IEEE-754 encodes -0.0 as 0x80000000,00000000 +d = immd -0.0 +hi = dhi2i d +reti hi diff --git a/js/src/lirasm/tests/softfloat/dhi2i.out b/js/src/lirasm/tests/softfloat/dhi2i.out new file mode 100644 index 00000000000..b0b45d5343b --- /dev/null +++ b/js/src/lirasm/tests/softfloat/dhi2i.out @@ -0,0 +1 @@ +Output is: -2147483648 diff --git a/js/src/lirasm/tests/softfloat/dlo2i.in b/js/src/lirasm/tests/softfloat/dlo2i.in new file mode 100644 index 00000000000..cdf01dc9665 --- /dev/null +++ b/js/src/lirasm/tests/softfloat/dlo2i.in @@ -0,0 +1,4 @@ +; IEEE-754 encodes the following constant as 0x3ff00000,ffffffff +d = immd 1.0000009536743162 +lo = dlo2i d +reti lo diff --git a/js/src/lirasm/tests/softfloat/dlo2i.out b/js/src/lirasm/tests/softfloat/dlo2i.out new file mode 100644 index 00000000000..7bf0fb6c35d --- /dev/null +++ b/js/src/lirasm/tests/softfloat/dlo2i.out @@ -0,0 +1 @@ +Output is: -1 diff --git a/js/src/lirasm/tests/softfloat/ii2d.in b/js/src/lirasm/tests/softfloat/ii2d.in new file mode 100644 index 00000000000..7189917b863 --- /dev/null +++ b/js/src/lirasm/tests/softfloat/ii2d.in @@ -0,0 +1,20 @@ +; It's very difficult to test that the 'lo' part is actually doing anything +; because it tends to get lost when lirasm dumps the result to the console. +; By far the easiest way to check this is to use dlo2i and dhi2i to see if we +; get what we started with (assuming that those instructions work). + +hi = immi 1127219201 ; 0x43300001 (positive, exponent of +52 ... +lo = immi -1 ; 0xffffffff (... mantissa of 0x100001ffffffff) +d = ii2d lo hi +hi2 = dhi2i d +lo2 = dlo2i d + +; XOR to check for differences, then OR the two results. 0 indicates success, +; but anything else indicates some kind of loss of data. +rhi = xori hi hi2 +rlo = xori lo lo2 + +res = ori rhi rlo + +reti res + diff --git a/js/src/lirasm/tests/random-opt.out b/js/src/lirasm/tests/softfloat/ii2d.out similarity index 100% rename from js/src/lirasm/tests/random-opt.out rename to js/src/lirasm/tests/softfloat/ii2d.out