This commit is contained in:
T0b1
2023-04-18 12:21:54 +02:00
commit 0bb8f5c3be
14 changed files with 4993 additions and 0 deletions

19
tests/alias.clif Normal file
View File

@@ -0,0 +1,19 @@
function %alias(i8) -> i8 {
block0(v0: i8):
v1 -> v0
return v1
}
function %double_alias(i8) -> i8 {
block0(v0: i8):
v1 -> v0
v2 -> v1
return v2
}
function %alias_inst() -> i8 {
block0:
v0 = iconst.i8 10
v1 -> v0
return v1
}

11
tests/bad_br.clif Normal file
View File

@@ -0,0 +1,11 @@
function u0:2(i32) -> i32 system_v {
block0(v0: i32):
v1 = iconst.i32 1
v2 = iconst.i32 2
v3 = iconst.i32 3
v4 = iconst.i32 4
br_table v0, block1(v4), [block1(v1), block1(v2), block1(v2), block1(v3)] ; v4 = 4, v1 = 1, v2 = 2, v2 = 2, v3 = 3
block1(v5: i32):
return v5
}

View File

@@ -0,0 +1,46 @@
function u0:4(i64 vmctx, i64, r64, i64) wasmtime_system_v {
gv0 = vmctx
gv1 = load.i64 notrap aligned readonly gv0+8
gv2 = load.i64 notrap aligned gv1
gv3 = vmctx
sig0 = (i64 vmctx, i64) wasmtime_system_v
sig1 = (i64 vmctx, i64, i32) -> i32 wasmtime_system_v
sig2 = (i64 vmctx, i64, i32, i64) wasmtime_system_v
sig3 = (i64 vmctx, i64, i32, i64, i32, f32, f64, r64, i64) wasmtime_system_v
fn0 = u0:0 sig0
fn1 = u0:1 sig1
fn2 = u0:2 sig2
fn3 = u0:3 sig3
stack_limit = gv2
block0(v0: i64, v1: i64, v2: r64, v3: i64):
v4 -> v0
v8 -> v0
v15 -> v0
v23 -> v0
v5 = load.i64 notrap aligned v0+72
v6 = load.i64 notrap aligned v0+80
call_indirect sig0, v5(v6, v0)
v9 = load.i64 notrap aligned v0+88
v10 = load.i64 notrap aligned v0+96
v7 = iconst.i32 0
v11 = call_indirect sig1, v9(v10, v0, v7) ; v7 = 0
v16 = load.i64 notrap aligned v0+104
v17 = load.i64 notrap aligned v0+112
v12 = iconst.i32 1
v13 = iadd v11, v12 ; v12 = 1
v14 = iconst.i64 3
call_indirect sig2, v16(v17, v0, v13, v14) ; v14 = 3
v24 = load.i64 notrap aligned v0+120
v25 = load.i64 notrap aligned v0+128
v18 = iconst.i32 100
v19 = iconst.i64 200
v20 = iconst.i32 300
v21 = f32const 0x1.900000p8
v22 = f64const 0x1.f400000000000p8
call_indirect sig3, v24(v25, v0, v18, v19, v20, v21, v22, v2, v3) ; v18 = 100, v19 = 200, v20 = 300, v21 = 0x1.900000p8, v22 = 0x1.f400000000000p8
jump block1
block1:
return
}

View File

@@ -0,0 +1,9 @@
function u0:3(i64, i64) system_v {
sig0 = (i8) -> i8 system_v
block0(v0: i64, v1: i64):
v2 = load.i8 notrap aligned v1
v3 = call_indirect sig0, v0(v2)
store notrap aligned v3, v1
return
}

21
tests/fibonacci.clif Normal file
View File

@@ -0,0 +1,21 @@
function %fibonacci(i32) -> i32 {
block0(v0: i32):
v1 = icmp_imm ule v0, 2
v2 = iconst.i32 1
; handle base case, n <= 2
brif v1, block3(v2), block1(v0, v2)
block1(v4: i32, v5:i32):
v6 = iconst.i32 1
v7 = iadd_imm v4, -2
jump block2(v7, v5, v6)
block2(v10: i32, v11: i32, v12: i32): ; params: n, fib(n-1), fib(n-2)
v13 = iadd v11, v12
v14 = iadd_imm v10, -1
v15 = icmp_imm eq v14, 0
brif v15, block3(v13), block2(v14, v13, v11)
block3(v20: i32): ; early return and end of loop
return v20
}

21
tests/simple.clif Normal file
View File

@@ -0,0 +1,21 @@
function u0:0(i64, i64) -> i64 system_v {
sig0 = (i64) -> i64 system_v
fn0 = u0:0 sig0
block0(v0: i64, v1: i64):
v4 = iconst.i64 50
brif v1, block1(v0), block2(v0)
block1(v2: i64):
v5 = iconst.i64 50
v6 = call fn0(v5) ; v5 = 50
v7 = iadd v2, v6
return v7
block2(v3: i64):
v8 = iconst.i64 10
v9 = iconst.i64 -20
v10 = iadd_imm v8, -20 ; v8 = 10
v11 = iadd v3, v10
return v11
}

8
tests/test.clif Normal file
View File

@@ -0,0 +1,8 @@
function u0:4(i64, i64) system_v {
sig0 = () -> i8 system_v
block0(v0: i64, v1: i64):
v2 = call_indirect sig0, v0()
store notrap aligned v2, v1
return
}