* cranelift: Restrict `br_table` to `i32` indices In #4498 it was proposed that we should only accept `i32` indices to `br_table`. The rationale for this is that larger types lead the users to a false sense of flexibility (since we don't support jump tables larger than u32's), and narrower types are not well tested paths that would be safer if we removed them. * cranelift: Reduce directly from i128 to i32 in Switch
41 lines
678 B
Plaintext
41 lines
678 B
Plaintext
test interpret
|
|
test run
|
|
target aarch64
|
|
target x86_64
|
|
target s390x
|
|
|
|
function %br_table_i32(i32) -> i32 {
|
|
jt0 = jump_table [block1, block2, block2, block3]
|
|
|
|
block0(v0: i32):
|
|
br_table v0, block4, jt0
|
|
|
|
block1:
|
|
v1 = iconst.i32 1
|
|
jump block5(v1)
|
|
|
|
block2:
|
|
v2 = iconst.i32 2
|
|
jump block5(v2)
|
|
|
|
block3:
|
|
v3 = iconst.i32 3
|
|
jump block5(v3)
|
|
|
|
block4:
|
|
v4 = iconst.i32 4
|
|
jump block5(v4)
|
|
|
|
block5(v5: i32):
|
|
v6 = iadd.i32 v0, v5
|
|
return v6
|
|
}
|
|
; run: %br_table_i32(0) == 1
|
|
; run: %br_table_i32(1) == 3
|
|
; run: %br_table_i32(2) == 4
|
|
; run: %br_table_i32(3) == 6
|
|
; run: %br_table_i32(4) == 8
|
|
; run: %br_table_i32(5) == 9
|
|
; run: %br_table_i32(6) == 10
|
|
; run: %br_table_i32(-1) == 3
|