]> git.lizzy.rs Git - rust.git/commit
Add new #[target_feature = "..."] attribute.
authorAndrew Gallant <jamslam@gmail.com>
Wed, 30 Nov 2016 00:02:00 +0000 (19:02 -0500)
committerAndrew Gallant <jamslam@gmail.com>
Wed, 30 Nov 2016 01:32:14 +0000 (20:32 -0500)
commit80ef1dbf2d51d2f2fd039d98a9150d2614e775b0
tree18be670959b4ae99ae1c707015a688e4b55d6b72
parent5de15be5ec9144f6701c8de606fdf83c6eefefef
Add new #[target_feature = "..."] attribute.

This commit adds a new attribute that instructs the compiler to emit
target specific code for a single function. For example, the following
function is permitted to use instructions that are part of SSE 4.2:

    #[target_feature = "+sse4.2"]
    fn foo() { ... }

In particular, use of this attribute does not require setting the
-C target-feature or -C target-cpu options on rustc.

This attribute does not have any protections built into it. For example,
nothing stops one from calling the above `foo` function on hosts without
SSE 4.2 support. Doing so may result in a SIGILL.

This commit also expands the target feature whitelist to include lzcnt,
popcnt and sse4a. Namely, lzcnt and popcnt have their own CPUID bits,
but were introduced with SSE4.
src/librustc_driver/target_features.rs
src/librustc_llvm/lib.rs
src/librustc_trans/attributes.rs
src/libsyntax/feature_gate.rs
src/test/compile-fail/gated-target_feature.rs [new file with mode: 0644]