-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
[WIP] Implement RFC2574 for FFI declarations #59238
Closed
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7834abd
Implement RFC2574: SIMD vectors in FFI
gnzlbg 685b46a
Make tests pass
gnzlbg f8b1944
add support for arm
gnzlbg b69935d
KILL ME: run x86, x86_64, arm, aarch64, and ppc64le jobs
gnzlbg db932d8
MMX support, aarch64, ppc, mips
gnzlbg 08b0f76
tidy
gnzlbg 1d34fbe
fix x86 error message
gnzlbg 83e9e1e
Add codegen test for target_feature on FFI
gnzlbg 8477a04
Do not typeck SIMD on FFI when under rustdoc
gnzlbg 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#![feature(repr_simd, simd_ffi)] | ||
#![allow(non_camel_case_types)] | ||
|
||
#[repr(simd)] | ||
struct v1024(i128, i128, i128, i128, i128, i128, i128, i128); | ||
|
||
extern { | ||
fn foo(x: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target-features | ||
fn bar(x: i32, y: v1024); //~ ERROR use of SIMD type `v1024` in FFI not supported by any target-features | ||
fn baz(x: i32) -> v1024; //~ ERROR use of SIMD type `v1024` in FFI not supported by any target-features | ||
|
||
fn qux_fail(x: v128); //~ ERROR use of SIMD type `v128` in FFI requires `#[target_feature(enable = "sse")]` | ||
#[target_feature(enable = "sse")] | ||
fn qux(x: v128); | ||
#[target_feature(enable = "sse4.2")] | ||
fn qux2(x: v128); | ||
#[target_feature(enable = "ssse3")] | ||
fn qux3(x: v128); | ||
#[target_feature(enable = "avx")] | ||
fn qux4(x: v128); | ||
#[target_feature(enable = "avx2")] | ||
fn qux5(x: v128); | ||
#[target_feature(enable = "avx512f")] | ||
fn qux6(x: v128); | ||
|
||
fn quux_fail(x: v256); //~ ERROR use of SIMD type `v256` in FFI requires `#[target_feature(enable = "avx")]` | ||
#[target_feature(enable = "sse4.2")] | ||
fn quux_fail2(x: v256); //~ ERROR use of SIMD type `v256` in FFI requires `#[target_feature(enable = "avx")]` | ||
#[target_feature(enable = "avx")] | ||
fn quux(x: v256); | ||
#[target_feature(enable = "avx2")] | ||
fn quux2(x: v256); | ||
#[target_feature(enable = "avx512f")] | ||
fn quux3(x: v256); | ||
|
||
fn quuux_fail(x: v512); //~ ERROR use of SIMD type `v256` in FFI requires `#[target_feature(enable = "avx512")]` | ||
#[target_feature(enable = "sse")] | ||
fn quuux_fail2(x: v512); //~ ERROR use of SIMD type `v256` in FFI requires `#[target_feature(enable = "avx512")]` | ||
#[target_feature(enable = "avx2")] | ||
fn quuux_fail3(x: v512); //~ ERROR use of SIMD type `v256` in FFI requires `#[target_feature(enable = "avx512")]` | ||
#[target_feature(enable = "avx512f")] | ||
fn quuux(x: v512); | ||
} | ||
|
||
fn main() {} | ||
|
||
#[repr(simd)] | ||
struct v128(i128); | ||
|
||
#[repr(simd)] | ||
struct v256(i128, i128); | ||
|
||
#[repr(simd)] | ||
struct v512(i128, i128, i128, i128); |
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,20 @@ | ||
error: use of SIMD type `v1024` in FFI not supported by any target features | ||
--> $DIR/simd-ffi.rs:8:15 | ||
| | ||
LL | fn foo(x: v1024); | ||
| ^^^^^ | ||
|
||
error: use of SIMD type `v1024` in FFI not supported by any target features | ||
--> $DIR/simd-ffi.rs:9:23 | ||
| | ||
LL | fn bar(x: i32, y: v1024); | ||
| ^^^^^ | ||
|
||
error: use of SIMD type `v1024` in FFI not supported by any target features | ||
--> $DIR/simd-ffi.rs:10:23 | ||
| | ||
LL | fn baz(x: i32) -> v1024; | ||
| ^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that this won't handle I think is:
but is that perhaps best left for a future implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not even sure if this is something we properly gate today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, and no, we don't gate this today:
both of these are allowed on stable Rust, and both should be rejected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also should gate foreign function definitions:
These also work on stable Rust.
I'll try to fix all of these issues as part of this PR. We can do a crater run afterwards, and see if we need to change any of these to warn instead of error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me!