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:
Jakob Stoklund Olesen
2016-09-15 15:27:37 -07:00
parent d221249e7f
commit 0b7f87b14c
13 changed files with 193 additions and 248 deletions

View File

@@ -0,0 +1,113 @@
; Parsing branches and jumps.
test cat
; Jumps with no arguments. The '()' empty argument list is optional.
function minimal() {
ebb0:
jump ebb1
ebb1:
jump ebb0()
}
; sameln: function minimal() {
; nextln: ebb0:
; nextln: jump ebb1
; nextln:
; nextln: ebb1:
; nextln: jump ebb0
; nextln: }
; Jumps with 1 arg.
function onearg(i32) {
ebb0(vx0: i32):
jump ebb1(vx0)
ebb1(vx1: i32):
jump ebb0(vx1)
}
; sameln: function onearg(i32) {
; nextln: ebb0(vx0: i32):
; nextln: jump ebb1(vx0)
; nextln:
; nextln: ebb1(vx1: i32):
; nextln: jump ebb0(vx1)
; nextln: }
; 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)
}
; sameln: function twoargs(i32, f32) {
; nextln: ebb0(vx0: i32, vx1: f32):
; nextln: jump ebb1(vx0, vx1)
; nextln:
; nextln: ebb1(vx2: i32, vx3: f32):
; nextln: jump ebb0(vx2, vx3)
; nextln: }
; Branches with no arguments. The '()' empty argument list is optional.
function minimal(i32) {
ebb0(vx0: i32):
brz vx0, ebb1
ebb1:
brnz vx0, ebb1()
}
; sameln: function minimal(i32) {
; nextln: ebb0(vx0: i32):
; nextln: brz vx0, ebb1
; nextln:
; nextln: ebb1:
; nextln: brnz vx0, ebb1
; nextln: }
function twoargs(i32, f32) {
ebb0(vx0: i32, vx1: f32):
brz vx0, ebb1(vx0, vx1)
ebb1(vx2: i32, vx3: f32):
brnz vx0, ebb0(vx2, vx3)
}
; sameln: function twoargs(i32, f32) {
; nextln: ebb0(vx0: i32, vx1: f32):
; nextln: brz vx0, ebb1(vx0, vx1)
; nextln:
; nextln: ebb1(vx2: i32, vx3: f32):
; nextln: brnz vx0, ebb0(vx2, vx3)
; nextln: }
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
}
; sameln: function jumptable(i32) {
; nextln: jt0 = jump_table 0
; nextln: jt1 = jump_table 0, 0, ebb0, ebb3, ebb1, ebb2
; nextln:
; nextln: ebb0(vx0: i32):
; nextln: br_table vx0, jt1
; nextln: trap
; nextln:
; nextln: ebb1:
; nextln: trap
; nextln:
; nextln: ebb2:
; nextln: trap
; nextln:
; nextln: ebb3:
; nextln: trap
; nextln: }

View File

@@ -0,0 +1,24 @@
; Parser tests for call and return syntax.
test cat
function mini() {
ebb1:
return
}
; sameln: function mini() {
; nextln: ebb0:
; nextln: return
; nextln: }
function r1() -> i32, f32 {
ebb1:
v1 = iconst.i32 3
v2 = f32const 0.0
return v1, v2
}
; sameln: function r1() -> i32, f32 {
; nextln: ebb0:
; nextln: v0 = iconst.i32 3
; nextln: v1 = f32const 0.0
; nextln: return v0, v1
; nextln: }

View File

@@ -0,0 +1,37 @@
; 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.
test cat
; Check that defining numbers are rewritten.
function defs() {
ebb100(v20: i32):
v1000 = iconst.i32x8 5
vx200 = f64const 0x4.0p0
trap
}
; sameln: function defs() {
; nextln: ebb0(vx0: i32):
; nextln: v0 = iconst.i32x8 5
; nextln: v1 = f64const 0x1.0000000000000p2
; nextln: trap
; nextln: }
; Using values.
function use_value() {
ebb100(v20: i32):
v1000 = iadd_imm v20, 5
vx200 = iadd v20, v1000
jump ebb100(v1000)
}
; sameln: function "use_value"() {
; nextln: ebb0(vx0: i32):
; nextln: v0 = iadd_imm vx0, 5
; nextln: v1 = iadd vx0, v0
; nextln: jump ebb0(v0)
; nextln: }

View File

@@ -0,0 +1,91 @@
test cat
; The smallest possible function.
function minimal() {
ebb0:
trap
}
; sameln: function minimal() {
; nextln: ebb0:
; nextln: trap
; nextln: }
; Create and use values.
; Polymorphic instructions with type suffix.
function ivalues() {
ebb0:
v0 = iconst.i32 2
v1 = iconst.i8 6
v2 = ishl v0, v1
}
; sameln: function ivalues() {
; nextln: ebb0:
; nextln: v0 = iconst.i32 2
; nextln: v1 = iconst.i8 6
; nextln: v2 = ishl v0, v1
; nextln: }
; Polymorphic istruction controlled by second operand.
function select() {
ebb0(vx0: i32, vx1: i32, vx2: b1):
v0 = select vx2, vx0, vx1
}
; sameln: function select() {
; nextln: ebb0(vx0: i32, vx1: i32, vx2: b1):
; nextln: v0 = select vx2, vx0, vx1
; nextln: }
; Lane indexes.
function lanes() {
ebb0:
v0 = iconst.i32x4 2
v1 = extractlane v0, 3
v2 = insertlane v0, 1, v1
}
; sameln: function lanes() {
; nextln: ebb0:
; nextln: v0 = iconst.i32x4 2
; nextln: v1 = extractlane v0, 3
; nextln: v2 = insertlane v0, 1, v1
; nextln: }
; 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
}
; sameln: function icmp(i32, i32) {
; nextln: ebb0(vx0: i32, vx1: i32):
; nextln: v0 = icmp eq, vx0, vx1
; nextln: v1 = icmp ult, vx0, vx1
; nextln: v2 = icmp sge, vx0, vx1
; nextln: }
; 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
}
; sameln: function fcmp(f32, f32) {
; nextln: ebb0(vx0: f32, vx1: f32):
; nextln: v0 = fcmp eq, vx0, vx1
; nextln: v1 = fcmp uno, vx0, vx1
; nextln: v2 = fcmp lt, vx0, vx1
; nextln: }
; 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
}
; sameln: function bitcast(i32, f32) {
; nextln: ebb0(vx0: i32, vx1: f32):
; nextln: v0 = bitcast.i8x4 vx0
; nextln: v1 = bitcast.i32 vx1
; nextln: }