Implement the 'test print-cfg' sub-test.
Move the CFG tests into the filetests directory. Remove the tests directory, there are no more shell-driven tests left.
This commit is contained in:
34
cranelift/filetests/cfg/loop.cton
Normal file
34
cranelift/filetests/cfg/loop.cton
Normal file
@@ -0,0 +1,34 @@
|
||||
; For testing cfg generation. This code is nonsense.
|
||||
test print-cfg
|
||||
|
||||
function nonsense(i32, i32) -> f32 {
|
||||
; check: digraph nonsense {
|
||||
; regex: I=\binst\d+\b
|
||||
; check: label="{ebb0 | <$(BRZ=$I)>brz ebb2 | <$(JUMP=$I)>jump ebb1}"]
|
||||
|
||||
ebb0(v1: i32, v2: i32):
|
||||
v3 = f64const 0x0.0
|
||||
brz v2, ebb2 ; unordered: ebb0:$BRZ -> ebb2
|
||||
v4 = iconst.i32 0
|
||||
jump ebb1(v4) ; unordered: ebb0:$JUMP -> ebb1
|
||||
|
||||
ebb1(v5: i32):
|
||||
v6 = imul_imm v5, 4
|
||||
v7 = iadd v1, v6
|
||||
v8 = f32const 0.0
|
||||
v9 = f32const 0.0
|
||||
v10 = f32const 0.0
|
||||
v11 = fadd v9, v10
|
||||
v12 = iadd_imm v5, 1
|
||||
v13 = icmp ult, v12, v2
|
||||
brnz v13, ebb1(v12) ; unordered: ebb1:inst12 -> ebb1
|
||||
v14 = f64const 0.0
|
||||
v15 = f64const 0.0
|
||||
v16 = fdiv v14, v15
|
||||
v17 = f32const 0.0
|
||||
return v17
|
||||
|
||||
ebb2:
|
||||
v100 = f32const 0.0
|
||||
return v100
|
||||
}
|
||||
20
cranelift/filetests/cfg/traps_early.cton
Normal file
20
cranelift/filetests/cfg/traps_early.cton
Normal file
@@ -0,0 +1,20 @@
|
||||
; For testing cfg generation. This code explores the implications of encountering
|
||||
; a terminating instruction before any connections have been made.
|
||||
test print-cfg
|
||||
|
||||
function nonsense(i32) {
|
||||
; check: digraph nonsense {
|
||||
|
||||
ebb0(v1: i32):
|
||||
trap
|
||||
brnz v1, ebb2 ; unordered: ebb0:inst1 -> ebb2
|
||||
jump ebb1 ; unordered: ebb0:inst2 -> ebb1
|
||||
|
||||
ebb1:
|
||||
v2 = iconst.i32 0
|
||||
v3 = iadd v1, v3
|
||||
jump ebb0(v3) ; unordered: ebb1:inst5 -> ebb0
|
||||
|
||||
ebb2:
|
||||
return v1
|
||||
}
|
||||
21
cranelift/filetests/cfg/unused_node.cton
Normal file
21
cranelift/filetests/cfg/unused_node.cton
Normal file
@@ -0,0 +1,21 @@
|
||||
; For testing cfg generation where some block is never reached.
|
||||
test print-cfg
|
||||
|
||||
function not_reached(i32) -> i32 {
|
||||
; check: digraph not_reached {
|
||||
; check: ebb0 [shape=record, label="{ebb0 | <inst0>brnz ebb2}"]
|
||||
; check: ebb1 [shape=record, label="{ebb1 | <inst4>jump ebb0}"]
|
||||
; check: ebb2 [shape=record, label="{ebb2}"]
|
||||
|
||||
ebb0(v0: i32):
|
||||
brnz v0, ebb2 ; unordered: ebb0:inst0 -> ebb2
|
||||
trap
|
||||
|
||||
ebb1:
|
||||
v1 = iconst.i32 1
|
||||
v2 = iadd v0, v1
|
||||
jump ebb0(v2) ; unordered: ebb1:inst4 -> ebb0
|
||||
|
||||
ebb2:
|
||||
return v0
|
||||
}
|
||||
Reference in New Issue
Block a user