Skip to content
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

Improve the support for SIMD vectors in FFI #21233

Merged
merged 7 commits into from Jan 17, 2015
Merged

Conversation

huonw
Copy link
Member

@huonw huonw commented Jan 16, 2015

This stops the compiler ICEing on the use of SIMD types in FFI signatures. It emits correct code for LLVM intrinsics, but I am quite unsure about the ABI handling in general so I've added a new feature gate simd_ffi to try to ensure people don't use it without realising there's a non-trivial risk of codegen brokenness.

Closes #20043.

This seems to work on x86-64, but I am not able to test on other
platforms.

cc rust-lang#20043
Unlike the intrinics in C, this types the SSE values base on integer
size. This matches the LLVM intrinsics which have concrete vector types
(`<4 x i32>` etc.), and is no loss of expressivity: if one is using a C
function that really takes an untyped integral SSE value, just give it
whatever Rust type makes most sense.
This seems to match what clang does on arm, but I cannot do any
experimentation with mips, but it matches how the LLVM intrinsics are
defined in any case...
@rust-highfive
Copy link
Collaborator

r? @Aatch

(rust_highfive has picked a reviewer for you, use r? to override)

This just compiles a test using SIMD in FFI (mostly importing LLVM
intrinsics) for almost all rustc's supported platforms, but not linking
it or running it, so there's absolutely no guarantee that this is correct.
I don't know if this handling of SIMD types is correct for the C ABI on
all platforms, so lets add an even finer feature gate than just the
`simd` one.

The `simd` one can be used with (relatively) little risk of complete
nonsense, the reason for it is that it is likely that things will
change. Using the types in FFI with an incorrect ABI will at best give
absolute nonsense results, but possibly cause serious breakage too, so
this is a step up in badness, hence a new feature gate.
bors added a commit that referenced this pull request Jan 17, 2015
This stops the compiler ICEing on the use of SIMD types in FFI signatures. It emits correct code for LLVM intrinsics, but I am quite unsure about the ABI handling in general so I've added a new feature gate `simd_ffi` to try to ensure people don't use it without realising there's a non-trivial risk of codegen brokenness.

Closes #20043.
@bors bors merged commit c8e0e95 into rust-lang:master Jan 17, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 24, 2015
As part of the audit for rust-lang#22820 the following duplicate feature
gate tests were removed:

* `box_patterns`
* `simd_ffi`

These tests for `box_patterns` and `simd_ffi` were added in rust-lang#23578,
however there were existing tests in rust-lang#20723 and rust-lang#21233 respectively.

r? @nrc
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 24, 2015
As part of the audit for rust-lang#22820 the following duplicate feature
gate tests were removed:

* `box_patterns`
* `simd_ffi`

These tests for `box_patterns` and `simd_ffi` were added in rust-lang#23578,
however there were existing tests in rust-lang#20723 and rust-lang#21233 respectively.

r? @nrc
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 25, 2015
As part of the audit for rust-lang#22820 the following duplicate feature
gate tests were removed:

* `box_patterns`
* `simd_ffi`

These tests for `box_patterns` and `simd_ffi` were added in rust-lang#23578,
however there were existing tests in rust-lang#20723 and rust-lang#21233 respectively.

r? @nrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ICE] "ty_size: unhandled type" when using a SIMD type in FFI
4 participants