Files
wasmtime/cranelift/filetests/filetests/runtests/uadd_overflow_trap.clif
Trevor Elliott 02620441c3 Add uadd_overflow_trap (#5123)
Add a new instruction uadd_overflow_trap, which is a fused version of iadd_ifcout and trapif. Adding this instruction removes a dependency on the iflags type, and would allow us to move closer to removing it entirely.

The instruction is defined for the i32 and i64 types only, and is currently only used in the legalization of heap_addr.
2022-10-27 09:43:15 -07:00

69 lines
1.3 KiB
Plaintext

test run
test interpret
target x86_64
target aarch64
target riscv64
target s390x
; NOTE: we don't currently have infrastructure for testing for traps, so these
; tests can only test the happy path. Once we eventually have annotations for
; expected traps, the cases here should be expanded.
function %f0(i32) -> i32 {
block0(v0: i32):
v1 = iconst.i32 0x7f
v2 = uadd_overflow_trap v0, v1, user0
return v2
}
; run: %f0(0) == 0x7f
; run: %f0(0x80) == 0xff
function %f1(i32) -> i32 {
block0(v0: i32):
v1 = iconst.i32 0x7f
v2 = uadd_overflow_trap v1, v0, user0
return v2
}
; run: %f0(0) == 0x7f
; run: %f0(0x80) == 0xff
function %f2(i32, i32) -> i32 {
block0(v0: i32, v1: i32):
v2 = uadd_overflow_trap v0, v1, user0
return v2
}
; run: %f2(0, 0) == 0x0
; run: %f2(0x80, 0x7f) == 0xff
function %f3(i64) -> i64 {
block0(v0: i64):
v1 = iconst.i64 0x7f
v2 = uadd_overflow_trap v0, v1, user0
return v2
}
; run: %f3(0) == 0x7f
; run: %f3(0x80) == 0xff
function %f4(i64) -> i64 {
block0(v0: i64):
v1 = iconst.i64 0x7f
v2 = uadd_overflow_trap v1, v0, user0
return v2
}
; run: %f4(0) == 0x7f
; run: %f4(0x80) == 0xff
function %f5(i64, i64) -> i64 {
block0(v0: i64, v1: i64):
v2 = uadd_overflow_trap v0, v1, user0
return v2
}
; run: %f5(0, 0) == 0x0
; run: %f5(0x80, 0x7f) == 0xff