Convert parser tests to filetests.
Create a new directory hierarchy under 'filetests' for all the tests that are run by 'cton-util test'. Convert the parser tests under 'tests/parser' to use 'test cat' and filecheck directives.
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
Parser tests
|
||||
============
|
||||
|
||||
This directory contains test cases for the Cretonne IL parser.
|
||||
|
||||
Each test case consists of a `foo.cton` input file and a `foo.ref` reference
|
||||
output file. Each input file is run through the `cton-util cat` command, and the
|
||||
output is compared against the reference file. If the two are identical, the
|
||||
test passes.
|
||||
@@ -1,60 +0,0 @@
|
||||
; Parsing branches and jumps.
|
||||
|
||||
; Jumps with no arguments. The '()' empty argument list is optional.
|
||||
function minimal() {
|
||||
ebb0:
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
jump ebb0()
|
||||
}
|
||||
|
||||
; Jumps with 1 arg.
|
||||
function onearg(i32) {
|
||||
ebb0(vx0: i32):
|
||||
jump ebb1(vx0)
|
||||
|
||||
ebb1(vx1: i32):
|
||||
jump ebb0(vx1)
|
||||
}
|
||||
|
||||
; Jumps with 2 args.
|
||||
function twoargs(i32, f32) {
|
||||
ebb0(vx0: i32, vx1: f32):
|
||||
jump ebb1(vx0, vx1)
|
||||
|
||||
ebb1(vx2: i32, vx3: f32):
|
||||
jump ebb0(vx2, vx3)
|
||||
}
|
||||
|
||||
; Branches with no arguments. The '()' empty argument list is optional.
|
||||
function minimal(i32) {
|
||||
ebb0(vx0: i32):
|
||||
brz vx0, ebb1
|
||||
|
||||
ebb1:
|
||||
brnz vx0, ebb1()
|
||||
}
|
||||
|
||||
function twoargs(i32, f32) {
|
||||
ebb0(vx0: i32, vx1: f32):
|
||||
brz vx0, ebb1(vx0, vx1)
|
||||
|
||||
ebb1(vx2: i32, vx3: f32):
|
||||
brnz vx0, ebb0(vx2, vx3)
|
||||
}
|
||||
|
||||
function jumptable(i32) {
|
||||
jt200 = jump_table 0, 0
|
||||
jt2 = jump_table 0, 0, ebb10, ebb40, ebb20, ebb30
|
||||
|
||||
ebb10(v3: i32):
|
||||
br_table v3, jt2
|
||||
trap
|
||||
ebb20:
|
||||
trap
|
||||
ebb30:
|
||||
trap
|
||||
ebb40:
|
||||
trap
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
function minimal() {
|
||||
ebb0:
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
jump ebb0
|
||||
}
|
||||
|
||||
function onearg(i32) {
|
||||
ebb0(vx0: i32):
|
||||
jump ebb1(vx0)
|
||||
|
||||
ebb1(vx1: i32):
|
||||
jump ebb0(vx1)
|
||||
}
|
||||
|
||||
function twoargs(i32, f32) {
|
||||
ebb0(vx0: i32, vx1: f32):
|
||||
jump ebb1(vx0, vx1)
|
||||
|
||||
ebb1(vx2: i32, vx3: f32):
|
||||
jump ebb0(vx2, vx3)
|
||||
}
|
||||
|
||||
function minimal(i32) {
|
||||
ebb0(vx0: i32):
|
||||
brz vx0, ebb1
|
||||
|
||||
ebb1:
|
||||
brnz vx0, ebb1
|
||||
}
|
||||
|
||||
function twoargs(i32, f32) {
|
||||
ebb0(vx0: i32, vx1: f32):
|
||||
brz vx0, ebb1(vx0, vx1)
|
||||
|
||||
ebb1(vx2: i32, vx3: f32):
|
||||
brnz vx0, ebb0(vx2, vx3)
|
||||
}
|
||||
|
||||
function jumptable(i32) {
|
||||
jt0 = jump_table 0
|
||||
jt1 = jump_table 0, 0, ebb0, ebb3, ebb1, ebb2
|
||||
|
||||
ebb0(vx0: i32):
|
||||
br_table vx0, jt1
|
||||
trap
|
||||
|
||||
ebb1:
|
||||
trap
|
||||
|
||||
ebb2:
|
||||
trap
|
||||
|
||||
ebb3:
|
||||
trap
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
; Parser tests for call and return syntax.
|
||||
|
||||
function mini() {
|
||||
ebb1:
|
||||
return
|
||||
}
|
||||
|
||||
function r1() -> i32, f32 {
|
||||
ebb1:
|
||||
v1 = iconst.i32 3
|
||||
v2 = f32const 0.0
|
||||
return v1, v2
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
function mini() {
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
function r1() -> i32, f32 {
|
||||
ebb0:
|
||||
v0 = iconst.i32 3
|
||||
v1 = f32const 0.0
|
||||
return v0, v1
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
; The .cton parser can't preserve the actual entity numbers in the input file
|
||||
; since entities are numbered as they are created. For entities declared in the
|
||||
; preamble, this is no problem, but for EBB and value references, mapping
|
||||
; source numbers to real numbers can be a problem.
|
||||
;
|
||||
; It is possible to refer to instructions and EBBs that have not yet been
|
||||
; defined in the lexical order, so the parser needs to rewrite these references
|
||||
; after the fact.
|
||||
|
||||
; Check that defining numbers are rewritten.
|
||||
function defs() {
|
||||
ebb100(v20: i32):
|
||||
v1000 = iconst.i32x8 5
|
||||
vx200 = f64const 0x4.0p0
|
||||
trap
|
||||
}
|
||||
|
||||
; Using values.
|
||||
function use_value() {
|
||||
ebb100(v20: i32):
|
||||
v1000 = iadd_imm v20, 5
|
||||
vx200 = iadd v20, v1000
|
||||
jump ebb100(v1000)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
function defs() {
|
||||
ebb0(vx0: i32):
|
||||
v0 = iconst.i32x8 5
|
||||
v1 = f64const 0x1.0000000000000p2
|
||||
trap
|
||||
}
|
||||
|
||||
function "use_value"() {
|
||||
ebb0(vx0: i32):
|
||||
v0 = iadd_imm vx0, 5
|
||||
v1 = iadd vx0, v0
|
||||
jump ebb0(v0)
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Go to tests directory.
|
||||
cd $(dirname "$0")/..
|
||||
|
||||
# The path to cton-util should be in $CTONUTIL.
|
||||
if [ -z "$CTONUTIL" ]; then
|
||||
CTONUTIL=../src/tools/target/debug/cton-util
|
||||
fi
|
||||
|
||||
if [ ! -x "$CTONUTIL" ]; then
|
||||
echo "Can't fund executable cton-util: $CTONUTIL" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -a fails
|
||||
|
||||
for testcase in $(find parser -name '*.cton'); do
|
||||
ref="${testcase}.ref"
|
||||
if [ ! -r "$ref" ]; then
|
||||
fails=(${fails[@]} "$testcase")
|
||||
echo MISSING: $ref
|
||||
elif diff -u "$ref" <("$CTONUTIL" cat "$testcase"); then
|
||||
echo OK $testcase
|
||||
else
|
||||
fails=(${fails[@]} "$testcase")
|
||||
echo FAIL $testcase
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#fails[@]} -ne 0 ]; then
|
||||
echo
|
||||
echo Failures:
|
||||
for f in "${fails[@]}"; do
|
||||
echo " $f"
|
||||
done
|
||||
exit 1
|
||||
else
|
||||
echo "All passed"
|
||||
fi
|
||||
@@ -1,52 +0,0 @@
|
||||
; The smallest possible function.
|
||||
function minimal() {
|
||||
ebb0:
|
||||
trap
|
||||
}
|
||||
|
||||
; Create and use values.
|
||||
; Polymorphic instructions with type suffix.
|
||||
function ivalues() {
|
||||
ebb0:
|
||||
v0 = iconst.i32 2
|
||||
v1 = iconst.i8 6
|
||||
v2 = ishl v0, v1
|
||||
}
|
||||
|
||||
; Polymorphic istruction controlled by second operand.
|
||||
function select() {
|
||||
ebb0(vx0: i32, vx1: i32, vx2: b1):
|
||||
v0 = select vx2, vx0, vx1
|
||||
}
|
||||
|
||||
; Lane indexes.
|
||||
function lanes() {
|
||||
ebb0:
|
||||
v0 = iconst.i32x4 2
|
||||
v1 = extractlane v0, 3
|
||||
v2 = insertlane v0, 1, v1
|
||||
}
|
||||
|
||||
; Integer condition codes.
|
||||
function icmp(i32, i32) {
|
||||
ebb0(vx0: i32, vx1: i32):
|
||||
v0 = icmp eq, vx0, vx1
|
||||
v1 = icmp ult, vx0, vx1
|
||||
v2 = icmp sge, vx0, vx1
|
||||
}
|
||||
|
||||
; Floating condition codes.
|
||||
function fcmp(f32, f32) {
|
||||
ebb0(vx0: f32, vx1: f32):
|
||||
v0 = fcmp eq, vx0, vx1
|
||||
v1 = fcmp uno, vx0, vx1
|
||||
v2 = fcmp lt, vx0, vx1
|
||||
}
|
||||
|
||||
; The bitcast instruction has two type variables: The controlling type variable
|
||||
; controls the outout type, and the input type is a free variable.
|
||||
function bitcast(i32, f32) {
|
||||
ebb0(vx0: i32, vx1: f32):
|
||||
v0 = bitcast.i8x4 vx0
|
||||
v1 = bitcast.i32 vx1
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
function minimal() {
|
||||
ebb0:
|
||||
trap
|
||||
}
|
||||
|
||||
function ivalues() {
|
||||
ebb0:
|
||||
v0 = iconst.i32 2
|
||||
v1 = iconst.i8 6
|
||||
v2 = ishl v0, v1
|
||||
}
|
||||
|
||||
function select() {
|
||||
ebb0(vx0: i32, vx1: i32, vx2: b1):
|
||||
v0 = select vx2, vx0, vx1
|
||||
}
|
||||
|
||||
function lanes() {
|
||||
ebb0:
|
||||
v0 = iconst.i32x4 2
|
||||
v1 = extractlane v0, 3
|
||||
v2 = insertlane v0, 1, v1
|
||||
}
|
||||
|
||||
function icmp(i32, i32) {
|
||||
ebb0(vx0: i32, vx1: i32):
|
||||
v0 = icmp eq, vx0, vx1
|
||||
v1 = icmp ult, vx0, vx1
|
||||
v2 = icmp sge, vx0, vx1
|
||||
}
|
||||
|
||||
function fcmp(f32, f32) {
|
||||
ebb0(vx0: f32, vx1: f32):
|
||||
v0 = fcmp eq, vx0, vx1
|
||||
v1 = fcmp uno, vx0, vx1
|
||||
v2 = fcmp lt, vx0, vx1
|
||||
}
|
||||
|
||||
function bitcast(i32, f32) {
|
||||
ebb0(vx0: i32, vx1: f32):
|
||||
v0 = bitcast.i8x4 vx0
|
||||
v1 = bitcast.i32 vx1
|
||||
}
|
||||
Reference in New Issue
Block a user