-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Vector bitcast support (AArch64 & Interpreter) #4820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,26 @@ | ||
| test run | ||
| target aarch64 | ||
| ; the interpreter, x86_64, and s390x do not support bitcasting to/from | ||
| ; references | ||
|
|
||
| function %bitcast_ir64(i64) -> b1 { | ||
| block0(v0: i64): | ||
| v1 = bitcast.r64 v0 | ||
| v2 = is_null v1 | ||
| return v2 | ||
| } | ||
| ; run: %bitcast_ir64(0) == true | ||
| ; run: %bitcast_ir64(18446744073709551615) == false | ||
| ; run: %bitcast_ir64(-1) == false | ||
| ; run: %bitcast_ir64(127) == false | ||
|
|
||
| function %bitcast_ri64(i64) -> i64 { | ||
| block0(v0: i64): | ||
| v1 = bitcast.r64 v0 | ||
| v2 = bitcast.i64 v1 | ||
| return v2 | ||
| } | ||
| ; run: %bitcast_ri64(0) == 0 | ||
| ; run: %bitcast_ri64(18446744073709551615) == 18446744073709551615 | ||
| ; run: %bitcast_ri64(-1) == -1 | ||
| ; run: %bitcast_ri64(127) == 127 | ||
69 changes: 69 additions & 0 deletions
69
cranelift/filetests/filetests/runtests/bitcast-same-type.clif
This file contains hidden or 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,69 @@ | ||
| test interpret | ||
| test run | ||
| target aarch64 | ||
| ; x86_64 and s390x do not support bitcasting to the same type as the input. | ||
|
|
||
| function %bitcast_i8(i8) -> i8 { | ||
| block0(v0: i8): | ||
| v1 = bitcast.i8 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_i8(0) == 0 | ||
| ; run: %bitcast_i8(42) == 42 | ||
| ; run: %bitcast_i8(255) == 255 | ||
|
|
||
| function %bitcast_i16(i16) -> i16 { | ||
| block0(v0: i16): | ||
| v1 = bitcast.i16 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_i16(0) == 0 | ||
| ; run: %bitcast_i16(42) == 42 | ||
| ; run: %bitcast_i16(65535) == 65535 | ||
|
|
||
| function %bitcast_i32(i32) -> i32 { | ||
| block0(v0: i32): | ||
| v1 = bitcast.i32 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_i32(0) == 0 | ||
| ; run: %bitcast_i32(42) == 42 | ||
| ; run: %bitcast_i32(4294967295) == 4294967295 | ||
|
|
||
| function %bitcast_i64(i64) -> i64 { | ||
| block0(v0: i64): | ||
| v1 = bitcast.i64 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_i64(0) == 0 | ||
| ; run: %bitcast_i64(42) == 42 | ||
| ; run: %bitcast_i64(18446744073709551615) == 18446744073709551615 | ||
|
|
||
| function %bitcast_i128(i128) -> i128 { | ||
| block0(v0: i128): | ||
| v1 = bitcast.i128 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_i128(0) == 0 | ||
| ; run: %bitcast_i128(42) == 42 | ||
| ; run: %bitcast_i128(200000000000000000000) == 200000000000000000000 | ||
|
|
||
| function %bitcast_f32(f32) -> f32 { | ||
| block0(v0: f32): | ||
| v1 = bitcast.f32 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_f32(0x0.0) == 0x0.0 | ||
| ; run: %bitcast_f32(0x1.0) == 0x1.0 | ||
| ; run: %bitcast_f32(-0x1.0) == -0x1.0 | ||
| ; run: %bitcast_f32(NaN) == NaN | ||
|
|
||
| function %bitcast_f64(f64) -> f64 { | ||
| block0(v0: f64): | ||
| v1 = bitcast.f64 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_f64(0x0.0) == 0x0.0 | ||
| ; run: %bitcast_f64(0x1.0) == 0x1.0 | ||
| ; run: %bitcast_f64(-0x1.0) == -0x1.0 | ||
| ; run: %bitcast_f64(NaN) == NaN |
This file contains hidden or 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,45 @@ | ||
| test interpret | ||
| test run | ||
| target aarch64 | ||
| target x86_64 | ||
| target s390x | ||
|
|
||
| function %bitcast_if32(i32) -> f32 { | ||
| block0(v0: i32): | ||
| v1 = bitcast.f32 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_if32(0) == 0x0.0 | ||
| ; run: %bitcast_if32(4294967295) == -NaN:0x3fffff | ||
| ; run: %bitcast_if32(-1) == -NaN:0x3fffff | ||
| ; run: %bitcast_if32(127) == 0x0.0000fep-126 | ||
|
|
||
| function %bitcast_fi32(f32) -> i32 { | ||
| block0(v0: f32): | ||
| v1 = bitcast.i32 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_fi32(0x0.0) == 0 | ||
| ; run: %bitcast_fi32(-NaN:0x3fffff) == 4294967295 | ||
| ; run: %bitcast_fi32(-NaN:0x3fffff) == -1 | ||
| ; run: %bitcast_fi32(0x0.0000fep-126) == 127 | ||
|
|
||
| function %bitcast_if64(i64) -> f64 { | ||
| block0(v0: i64): | ||
| v1 = bitcast.f64 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_if64(0) == 0x0.0 | ||
| ; run: %bitcast_if64(18446744073709551615) == -NaN:0x7ffffffffffff | ||
| ; run: %bitcast_if64(-1) == -NaN:0x7ffffffffffff | ||
| ; run: %bitcast_if64(127) == 0x0.000000000007fp-1022 | ||
|
|
||
| function %bitcast_fi64(f64) -> i64 { | ||
| block0(v0: f64): | ||
| v1 = bitcast.i64 v0 | ||
| return v1 | ||
| } | ||
| ; run: %bitcast_fi64(0x0.0) == 0 | ||
| ; run: %bitcast_fi64(-NaN:0x7ffffffffffff) == 18446744073709551615 | ||
| ; run: %bitcast_fi64(-NaN:0x7ffffffffffff) == -1 | ||
| ; run: %bitcast_fi64(0x0.000000000007fp-1022) == 127 |
This file contains hidden or 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,121 @@ | ||
| test interpret | ||
| test run | ||
| target aarch64 | ||
| target s390x | ||
| ; x86_64 regards this as an unused opcode. | ||
|
|
||
| function %copy_i8(i8) -> i8 { | ||
| block0(v0: i8): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_i8(0) == 0 | ||
| ; run: %copy_i8(255) == 255 | ||
| ; run: %copy_i8(-1) == -1 | ||
| ; run: %copy_i8(127) == 127 | ||
|
|
||
| function %copy_i16(i16) -> i16 { | ||
| block0(v0: i16): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_i16(0) == 0 | ||
| ; run: %copy_i16(65535) == 65535 | ||
| ; run: %copy_i16(-1) == -1 | ||
| ; run: %copy_i16(127) == 127 | ||
|
|
||
| function %copy_i32(i32) -> i32 { | ||
| block0(v0: i32): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_i32(0) == 0 | ||
| ; run: %copy_i32(4294967295) == 4294967295 | ||
| ; run: %copy_i32(-1) == -1 | ||
| ; run: %copy_i32(127) == 127 | ||
|
|
||
| function %copy_i64(i64) -> i64 { | ||
| block0(v0: i64): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_i64(0) == 0 | ||
| ; run: %copy_i64(18446744073709551615) == 18446744073709551615 | ||
| ; run: %copy_i64(-1) == -1 | ||
| ; run: %copy_i64(127) == 127 | ||
|
|
||
| function %copy_b1(b1) -> b1 { | ||
| block0(v0: b1): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_b1(false) == false | ||
| ; run: %copy_b1(true) == true | ||
|
|
||
| function %copy_b8(b8) -> b8 { | ||
| block0(v0: b8): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_b8(false) == false | ||
| ; run: %copy_b8(true) == true | ||
|
|
||
| function %copy_b16(b16) -> b16 { | ||
| block0(v0: b16): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_b16(false) == false | ||
| ; run: %copy_b16(true) == true | ||
|
|
||
| function %copy_b32(b32) -> b32 { | ||
| block0(v0: b32): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_b32(false) == false | ||
| ; run: %copy_b32(true) == true | ||
|
|
||
| function %copy_b64(b64) -> b64 { | ||
| block0(v0: b64): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_b64(false) == false | ||
| ; run: %copy_b64(true) == true | ||
|
|
||
| function %copy_f32(f32) -> f32 { | ||
| block0(v0: f32): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_f32(0x1.0) == 0x1.0 | ||
| ; run: %copy_f32(0x1.0p10) == 0x1.0p10 | ||
|
|
||
| ; run: %copy_f32(0x0.0) == 0x0.0 | ||
| ; run: %copy_f32(-0x0.0) == -0x0.0 | ||
| ; run: %copy_f32(+Inf) == +Inf | ||
| ; run: %copy_f32(-Inf) == -Inf | ||
| ; run: %copy_f32(0x1.000002p-23) == 0x1.000002p-23 | ||
| ; run: %copy_f32(0x1.fffffep127) == 0x1.fffffep127 | ||
| ; run: %copy_f32(0x1.000000p-126) == 0x1.000000p-126 | ||
| ; run: %copy_f32(0x0.800002p-126) == 0x0.800002p-126 | ||
| ; run: %copy_f32(-0x0.800000p-126) == -0x0.800000p-126 | ||
|
|
||
| function %copy_f64(f64) -> f64 { | ||
| block0(v0: f64): | ||
| v1 = copy v0 | ||
| return v1 | ||
| } | ||
| ; run: %copy_f64(0x2.0) == 0x2.0 | ||
| ; run: %copy_f64(0x1.0p11) == 0x1.0p11 | ||
|
|
||
| ; run: %copy_f64(0x0.0) == 0x0.0 | ||
| ; run: %copy_f64(-0x0.0) == -0x0.0 | ||
| ; run: %copy_f64(+Inf) == +Inf | ||
| ; run: %copy_f64(-Inf) == -Inf | ||
| ; run: %copy_f64(0x1.0000000000002p-52) == 0x1.0000000000002p-52 | ||
| ; run: %copy_f64(0x1.fffffffffffffp1023) == 0x1.fffffffffffffp1023 | ||
| ; run: %copy_f64(0x1.0000000000000p-1022) == 0x1.0000000000000p-1022 | ||
| ; run: %copy_f64(0x0.8000000000002p-1022) == 0x0.8000000000002p-1022 | ||
| ; run: %copy_f64(-0x0.8000000000000p-1022) == -0x0.8000000000000p-1022 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.