Add a WebAssembly filetests directory.
Start adding little 'test compile' test cases which check that the full compilation pipeline works for each WebAssembly instruction.
This commit is contained in:
62
filetests/wasm/i32-arith.cton
Normal file
62
filetests/wasm/i32-arith.cton
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
; Test basic code generation for i32 arithmetic WebAssembly instructions.
|
||||||
|
test compile
|
||||||
|
|
||||||
|
set is_64bit
|
||||||
|
isa intel
|
||||||
|
|
||||||
|
; Constants.
|
||||||
|
|
||||||
|
function %i32_const() -> i32 {
|
||||||
|
ebb0:
|
||||||
|
v0 = iconst.i32 0x8765_4321
|
||||||
|
return v0
|
||||||
|
}
|
||||||
|
|
||||||
|
; Unary operations.
|
||||||
|
|
||||||
|
; function %i32_clz(i32) -> i32
|
||||||
|
; function %i32_ctz(i32) -> i32
|
||||||
|
; function %i32_popcnt(i32) -> i32
|
||||||
|
|
||||||
|
; Binary operations.
|
||||||
|
|
||||||
|
function %i32_add(i32, i32) -> i32 {
|
||||||
|
ebb0(v0: i32, v1: i32):
|
||||||
|
v2 = iadd v0, v1
|
||||||
|
return v2
|
||||||
|
}
|
||||||
|
|
||||||
|
function %i32_sub(i32, i32) -> i32 {
|
||||||
|
ebb0(v0: i32, v1: i32):
|
||||||
|
v2 = isub v0, v1
|
||||||
|
return v2
|
||||||
|
}
|
||||||
|
|
||||||
|
; function %i32_mul(i32, i32) -> i32
|
||||||
|
; function %i32_div(i32, i32) -> i32
|
||||||
|
; function %i32_rem_s(i32, i32) -> i32
|
||||||
|
; function %i32_rem_u(i32, i32) -> i32
|
||||||
|
|
||||||
|
function %i32_and(i32, i32) -> i32 {
|
||||||
|
ebb0(v0: i32, v1: i32):
|
||||||
|
v2 = band v0, v1
|
||||||
|
return v2
|
||||||
|
}
|
||||||
|
|
||||||
|
function %i32_or(i32, i32) -> i32 {
|
||||||
|
ebb0(v0: i32, v1: i32):
|
||||||
|
v2 = bor v0, v1
|
||||||
|
return v2
|
||||||
|
}
|
||||||
|
|
||||||
|
function %i32_xor(i32, i32) -> i32 {
|
||||||
|
ebb0(v0: i32, v1: i32):
|
||||||
|
v2 = bxor v0, v1
|
||||||
|
return v2
|
||||||
|
}
|
||||||
|
|
||||||
|
; function %i32_shl(i32, i32) -> i32
|
||||||
|
; function %i32_shr_s(i32, i32) -> i32
|
||||||
|
; function %i32_shr_u(i32, i32) -> i32
|
||||||
|
; function %i32_rotl(i32, i32) -> i32
|
||||||
|
; function %i32_rotr(i32, i32) -> i32
|
||||||
Reference in New Issue
Block a user