forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interpreter: Implement floating point conversions (bytecodealliance#4884
) * Interpreter: Implement floating point conversions Implemented the following opcodes for the interpreter: - `FcvtToUint` - `FcvtToSint` - `FcvtToUintSat` - `FcvtToSintSat` - `FcvtFromUint` - `FcvtFromSint` - `FcvtLowFromSint` - `FvpromoteLow` - `Fvdemote` Copyright (c) 2022 Arm Limited * Fix `I128` bounds checks for `FcvtTo{U,S}int{_,Sat}` Copyright (c) 2022 Arm Limited * Fix broken test Copyright (c) 2022 Arm Limited
- Loading branch information
1 parent
7772f11
commit 22b96cc
Showing
6 changed files
with
284 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
test interpret | ||
test run | ||
target aarch64 | ||
target s390x | ||
target x86_64 | ||
|
||
function %fcvt_to_sint(f32) -> i32 { | ||
block0(v0: f32): | ||
v1 = fcvt_to_sint.i32 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_sint(0x0.0) == 0 | ||
; run: %fcvt_to_sint(0x1.0) == 1 | ||
; run: %fcvt_to_sint(0x1.d6f346p26) == 123456792 | ||
; run: %fcvt_to_sint(0x8.1) == 8 | ||
|
||
function %fcvt_to_uint(f32) -> i32 { | ||
block0(v0:f32): | ||
v1 = fcvt_to_uint.i32 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_uint(0x0.0) == 0 | ||
; run: %fcvt_to_uint(0x1.0) == 1 | ||
; run: %fcvt_to_uint(0x4.2) == 4 | ||
; run: %fcvt_to_uint(0x4.6) == 4 | ||
; run: %fcvt_to_uint(0x1.d6f346p26) == 123456792 | ||
; run: %fcvt_to_uint(0xB2D05E00.0) == 3000000000 | ||
|
||
function %fcvt_to_sint_sat(f32) -> i32 { | ||
block0(v0: f32): | ||
v1 = fcvt_to_sint_sat.i32 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_sint_sat(0x0.0) == 0 | ||
; run: %fcvt_to_sint_sat(0x1.0) == 1 | ||
; run: %fcvt_to_sint_sat(0x1.d6f346p26) == 123456792 | ||
; run: %fcvt_to_sint_sat(0x8.1) == 8 | ||
; run: %fcvt_to_sint_sat(-0x1.0) == -1 | ||
; run: %fcvt_to_sint_sat(0x1.fffffep127) == 2147483647 | ||
; run: %fcvt_to_sint_sat(-0x1.fffffep127) == -2147483648 | ||
|
||
function %fcvt_to_uint_sat(f32) -> i32 { | ||
block0(v0:f32): | ||
v1 = fcvt_to_uint_sat.i32 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_uint_sat(0x0.0) == 0 | ||
; run: %fcvt_to_uint_sat(0x1.0) == 1 | ||
; run: %fcvt_to_uint_sat(0x4.2) == 4 | ||
; run: %fcvt_to_uint_sat(0x4.6) == 4 | ||
; run: %fcvt_to_uint_sat(0x1.d6f346p26) == 123456792 | ||
; run: %fcvt_to_uint_sat(0xB2D05E00.0) == 3000000000 | ||
; run: %fcvt_to_uint_sat(-0x1.0) == 0 | ||
; run: %fcvt_to_uint_sat(0x1.fffffep127) == 4294967295 | ||
; run: %fcvt_to_uint_sat(-0x1.fffffep127) == 0 |
File renamed without changes.
52 changes: 52 additions & 0 deletions
52
cranelift/filetests/filetests/runtests/i128-conversion.clif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
test interpret | ||
; `fcvt_to_{u,s}int.i128` not currently supported by any backend. | ||
|
||
function %fcvt_to_uint_i128(f32) -> i128 { | ||
block0(v0: f32): | ||
v1 = fcvt_to_uint.i128 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_uint_i128(0x0.0) == 0 | ||
; run: %fcvt_to_uint_i128(0x1.0) == 1 | ||
; run: %fcvt_to_uint_i128(0x1.0p31) == 2147483648 | ||
; run: %fcvt_to_uint_i128(0x1.fffffp31) == 4294965248 | ||
; run: %fcvt_to_uint_i128(0x1.0p63) == 9223372036854775808 | ||
; run: %fcvt_to_uint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727 | ||
|
||
function %fcvt_to_sint_i128(f32) -> i128 { | ||
block0(v0: f32): | ||
v1 = fcvt_to_sint.i128 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_sint_i128(0x0.0) == 0 | ||
; run: %fcvt_to_sint_i128(0x1.0) == 1 | ||
; run: %fcvt_to_sint_i128(0x1.0p31) == 2147483648 | ||
; run: %fcvt_to_sint_i128(0x1.fffffp31) == 4294965248 | ||
; run: %fcvt_to_sint_i128(-0x1.fffffp31) == -4294965248 | ||
; run: %fcvt_to_sint_i128(0x1.0p63) == 9223372036854775808 | ||
; run: %fcvt_to_sint_i128(-0x1.0p63) == -9223372036854775808 | ||
; run: %fcvt_to_sint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727 | ||
|
||
function %fcvt_to_uint_sat_i128(f32) -> i128 { | ||
block0(v0: f32): | ||
v1 = fcvt_to_uint_sat.i128 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_uint_sat_i128(0x0.0) == 0 | ||
; run: %fcvt_to_uint_sat_i128(0x1.0) == 1 | ||
; run: %fcvt_to_uint_sat_i128(0x1.0p31) == 2147483648 | ||
; run: %fcvt_to_uint_sat_i128(0x1.fffffp31) == 4294965248 | ||
; run: %fcvt_to_uint_sat_i128(-0x1.fffffp31) == 0 | ||
; run: %fcvt_to_uint_sat_i128(0x1.fffffep127) == 170141183460469231731687303715884105727 | ||
|
||
function %fcvt_to_sint_sat_i128(f32) -> i128 { | ||
block0(v0: f32): | ||
v1 = fcvt_to_sint_sat.i128 v0 | ||
return v1 | ||
} | ||
; run: %fcvt_to_sint_sat_i128(0x0.0) == 0 | ||
; run: %fcvt_to_sint_sat_i128(0x1.0) == 1 | ||
; run: %fcvt_to_sint_sat_i128(0x1.0p31) == 2147483648 | ||
; run: %fcvt_to_sint_sat_i128(0x1.fffffp31) == 4294965248 | ||
; run: %fcvt_to_sint_sat_i128(-0x1.fffffp31) == -4294965248 | ||
; run: %fcvt_to_sint_sat_i128(0x1.fffffep127) == 170141183460469231731687303715884105727 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters