As jump tables are used by at most one br_table instruction, inline their definition in those instructions instead of requiring them to be declared as function-level metadata.
61 lines
909 B
Plaintext
61 lines
909 B
Plaintext
; Test basic code generation for control flow WebAssembly instructions.
|
|
test compile
|
|
|
|
target aarch64
|
|
target i686 haswell
|
|
target x86_64 haswell
|
|
|
|
function %br_if(i32) -> i32 {
|
|
block0(v0: i32):
|
|
v1 = iconst.i32 1
|
|
brif v0, block2, block1(v1)
|
|
|
|
block1(v2: i32):
|
|
return v2
|
|
|
|
block2:
|
|
jump block1(v0)
|
|
}
|
|
|
|
function %br_if_not(i32) -> i32 {
|
|
block0(v0: i32):
|
|
v1 = iconst.i32 1
|
|
brif v0, block1(v0), block2
|
|
|
|
block1(v2: i32):
|
|
return v2
|
|
|
|
block2:
|
|
jump block1(v0)
|
|
}
|
|
|
|
function %br_if_fallthrough(i32) -> i32 {
|
|
block0(v0: i32):
|
|
v1 = iconst.i32 1
|
|
; This jump gets converted to a fallthrough.
|
|
brif v0, block1(v0), block1(v1)
|
|
|
|
block1(v2: i32):
|
|
return v2
|
|
}
|
|
|
|
function %undefined() {
|
|
block0:
|
|
trap user0
|
|
}
|
|
|
|
function %br_table(i32) {
|
|
block0(v0: i32):
|
|
br_table v0, block4, [block3, block1, block2]
|
|
|
|
block4:
|
|
trap heap_oob
|
|
|
|
block1:
|
|
return
|
|
block2:
|
|
return
|
|
block3:
|
|
return
|
|
}
|