Files
wasmtime/cranelift/filetests/filetests/runtests/stack.clif
yuyang-ok cdecc858b4 add riscv64 backend for cranelift. (#4271)
Add a RISC-V 64 (`riscv64`, RV64GC) backend.

Co-authored-by: yuyang <756445638@qq.com>
Co-authored-by: Chris Fallin <chris@cfallin.org>
Co-authored-by: Afonso Bordado <afonsobordado@az8.co>
2022-09-27 17:30:31 -07:00

107 lines
2.3 KiB
Plaintext

test interpret
test run
; Disable stack probes since these tests don't require them
set enable_probestack=false
target x86_64
target s390x
target aarch64
target riscv64
function %stack_simple(i64) -> i64 {
ss0 = explicit_slot 8
block0(v0: i64):
stack_store.i64 v0, ss0
v1 = stack_load.i64 ss0
return v1
}
; run: %stack_simple(0) == 0
; run: %stack_simple(1) == 1
; run: %stack_simple(-1) == -1
function %stack_offset(i64) -> i64 {
ss0 = explicit_slot 16
block0(v0: i64):
stack_store.i64 v0, ss0+8
v1 = stack_load.i64 ss0+8
return v1
}
; run: %stack_offset(0) == 0
; run: %stack_offset(1) == 1
; run: %stack_offset(-1) == -1
function %offset_unaligned(i64) -> i64 {
ss0 = explicit_slot 11
block0(v0: i64):
stack_store.i64 v0, ss0+3
v1 = stack_load.i64 ss0+3
return v1
}
; run: %offset_unaligned(0) == 0
; run: %offset_unaligned(1) == 1
; run: %offset_unaligned(-1) == -1
function %multi_slot_stack(i64, i64) -> i64 {
ss0 = explicit_slot 8
ss1 = explicit_slot 8
block0(v0: i64, v1: i64):
stack_store.i64 v0, ss0
stack_store.i64 v1, ss1
v2 = stack_load.i64 ss0
v3 = stack_load.i64 ss1
v4 = iadd.i64 v2, v3
return v4
}
; run: %multi_slot_stack(0, 1) == 1
; run: %multi_slot_stack(1, 2) == 3
function %multi_slot_out_of_bounds_writes(i8, i64) -> i8, i64 {
ss0 = explicit_slot 1
ss1 = explicit_slot 8
block0(v0: i8, v1: i64):
stack_store.i8 v0, ss0
stack_store.i64 v1, ss1
v2 = stack_load.i8 ss0
v3 = stack_load.i64 ss1
return v2, v3
}
; run: %multi_slot_out_of_bounds_writes(10, 1) == [10, 1]
; run: %multi_slot_out_of_bounds_writes(0, 2) == [0, 2]
function %multi_slot_offset_writes(i8, i64) -> i8, i64 {
ss0 = explicit_slot 8
ss1 = explicit_slot 8
block0(v0: i8, v1: i64):
stack_store.i8 v0, ss0
stack_store.i64 v1, ss1
v2 = stack_load.i8 ss0
v3 = stack_load.i64 ss1
return v2, v3
}
; run: %multi_slot_offset_writes(0, 1) == [0, 1]
; run: %multi_slot_offset_writes(1, 2) == [1, 2]
function %huge_slots(i64) -> i64 {
ss0 = explicit_slot 1048576 ; 1MB Slot
block0(v0: i64):
stack_store.i64 v0, ss0+1048568 ; Store at 1MB - 8bytes
v1 = stack_load.i64 ss0+1048568
return v1
}
; run: %huge_slots(0) == 0
; run: %huge_slots(1) == 1
; run: %huge_slots(-1) == -1