Files
wasmtime/tests/parser/branch.cton
Jakob Stoklund Olesen 20fc675fc0 Parse the BranchTable instruction format.
Resolve the jump table reference immediately since all jump tables are declared
in the preamble.
2016-07-22 15:16:14 -07:00

61 lines
946 B
Plaintext

; 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
}