-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Support detecting all llc's x86 target features #34397
Conversation
This commit adds support for detecting all of llc's target features for the x86/x86_64 architectures. Closes rust-lang#30462. Helps with rust-lang#29717 and rust-lang#34382.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
pinging also: @huonw @alexcrichton BTW: This PR doesn't solve the root of the issue (we should be getting the features that are available from LLVM directly instead of maintaining our own list). |
The original implementation of feature detection provided the complete list of LLVM features in Rust, but it was modified to only expose those that are explicitly whitelisted as per #31709 (comment) |
@gnzlbg before #31709 the available features were computed on a best-effort basis from the flags passed to the compiler; in #31709 I kept the pre-existing list of features from here: https://github.com/rust-lang/rust/pull/31709/files#diff-787403961a3c37598ae191c2d68be445L35 I think @huonw determined the list of features when as part of his SIMD work. |
So is @huonw the person responsible for white listing new features? Or what is the procedure for white listing new features? I just need a couple of feature flags (bmi, bmi2, abm, tbm, sse4a) but the only response I got in the forum is that if we want to not deal with this problem every time somebody needs to do something that requires a feature flag that is not exposed, the best thing would probably be to just expose all the ones that are available. |
Yeah as pointed out by @ranma42 these features were historically hand-selected and parsed in an ad-hoc fashion (primarily for SIMD support). In #31709 it was fixed to compute these features directly from LLVM to have a more robust implementation (e.g. working with As a result, to add new features, we basically need to follow a checklist like:
We've avoided "kitchen sink" style commits which just add a load of features that LLVM has to the compiler, as it's unfortunately easy for something we don't want to sneak in by accident. Would it be possible to trim this list down to just what's needed? |
I just need "bmi, bmi2, abm, tbm, sse4a" so I can trim the list down to that. Those doing encryption might want
Is there an easy way to do that? That would allow exposing |
cc @rust-lang/tools or @rust-lang/lang, thoughts on the names for these features? Note that these are not stable today ( |
I don't have any better ideas. lgtm |
Is there a command in rustc to list these values? |
FYI I will probably implement intrinsics for those instruction sets over the next couple of days (there are LLVM IR functions for most of the instructions in those instruction sets), so that I can write a crate that exposes the intrinsics as rust functions (in the same spirit of the SIMD crate, but without defining new types or traits, just the "bare" intrinsics).
I think we could stabilize EDIT: In particular, I don't think we could ever stabilize the feature names. What if LLVM drops support for some architecture, or renames/coalesces them, adds/removes intrinsics to some features over time, ... I don't think it is worth going to something like "feature versioning" unless it turns out to really cause problems in practice. |
@brson |
Superseeded by PR #34412 , which not only adds the targets but also implements the intrinsics in the compiler. |
This commit adds support for detecting all of llc's target features for the x86/x86_64 architectures.
Closes #30462.
Helps with #29717 and #34382.