Skip to content

Commit

Permalink
Add a WebAssembly filetests directory.
Browse files Browse the repository at this point in the history
Start adding little 'test compile' test cases which check that the full
compilation pipeline works for each WebAssembly instruction.
  • Loading branch information
Jakob Stoklund Olesen committed Jul 12, 2017
1 parent 6cc729a commit 3d738d0
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions filetests/wasm/i32-arith.cton
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3d738d0

Please sign in to comment.