Commit Graph

17 Commits

Author SHA1 Message Date
Fabjan Sukalia 4d23ca4b5f rustc: Whitelist the FMA target feature
This commit adds the entry `"fma\0"` to the whitelist for the x86
target. LLVM already supports fma but rustc did not directly. Previously
rustc permitted `+fma` in the target-feature argument and enabled the use
of FMA instructions, but it did not list it in the configuration and
attributes.

fixes #40406
2017-03-10 23:57:58 +01:00
Simonas Kazlauskas b2cf6df875 Add intrinsics & target features for rd{rand,seed} 2016-12-22 23:53:30 +02:00
Andrew Gallant 80ef1dbf2d 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.
2016-11-29 20:32:14 -05:00
Jeffrey Seyfried e85a0d70b8 Use `Symbol` instead of `InternedString` in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Jeffrey Seyfried d2f8fb0a0a Move `syntax::util::interner` -> `syntax::symbol`, cleanup. 2016-11-20 23:40:20 +00:00
Jeffrey Seyfried 4b9b0d3474 Refactor `CrateConfig`. 2016-11-20 12:35:57 +00:00
Jeffrey Seyfried a2626410d7 Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s. 2016-11-20 11:46:06 +00:00
Alex Crichton 06242ff15d rustc: Implement #[link(cfg(..))] and crt-static
This commit is an implementation of [RFC 1721] which adds a new target feature
to the compiler, `crt-static`, which can be used to select how the C runtime for
a target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.

[RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md

This commit first adds the new target-feature, `crt-static`. If enabled, then
the `cfg(target_feature = "crt-static")` will be available. Targets like musl
will have this enabled by default. This feature can be controlled through the
standard target-feature interface, `-C target-feature=+crt-static` or
`-C target-feature=-crt-static`.

Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the
`crt-static` semantics we want with libc. The exact behavior of this attribute
is a little squishy, but it's intended to be a forever-unstable
implementation detail of the liblibc crate.

Specifically the `#[link(cfg(..))]` annotation means that the `#[link]`
directive is only active in a compilation unit if that `cfg` value is satisfied.
For example when compiling an rlib, these directives are just encoded and
ignored for dylibs, and all staticlibs are continued to be put into the rlib as
usual. When placing that rlib into a staticlib, executable, or dylib, however,
the `cfg` is evaluated *as if it were defined in the final artifact* and the
library is decided to be linked or not.

Essentially, what'll happen is:

* On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be
  linked to.
* On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be
  linked to.
* On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib
  are removed and `-lc` is passed instead.
* On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib
  are used and `-lc` is not passed.

This commit does **not** include an update to the liblibc module to implement
these changes. I plan to do that just after the 1.14.0 beta release is cut to
ensure we get ample time to test this feature.

cc #37406
2016-11-16 07:00:09 -08:00
Srinivas Reddy Thatiparthy f32ce9c142
run rustfmt on librustc_driver folder 2016-10-30 18:26:51 +05:30
gnzlbg 483bec790b Add target_features for the bit manipulation instruction sets: BMI 1.0, BMI 2.0, and TBM. 2016-06-22 17:11:17 +02:00
Andrea Canciani ce99a5e5d8 Check that the feature strings are well-formed
Assert that the feature strings are NUL terminated, so that they will
be well-formed as C strings.

This is a safety check to ease the maintaninace and update of the
feature lists.
2016-04-20 09:09:30 +02:00
Andrea Canciani deaa2fe753 Make the feature whitelists constants
This simplifies the code a bit and makes the types nicer, too.
2016-04-20 09:08:25 +02:00
Andrea Canciani 5879ee1eca Distinguish different `vfp?` features
The different generations of ARM floating point VFP correspond to the
LLVM CPU features named `vfp2`, `vfp3`, and `vfp4`; they are now
exposed in Rust under the same names.

This commit fixes some crashes that would occour when checking if the
`vfp` feature exists (the crash occurs because the linear scan of the
LLVM feature goes past the end of the features whenever it searches
for a feature that does not exist in the LLVM tables).
2016-04-19 17:48:51 +02:00
Andrea Canciani f942c28900 Do not intern NUL terminators
The C representation needed by LLVM requires strings to be
NUL-terminated, but on the Rust side they should not contain unwanted
NULs.
2016-04-19 17:44:36 +02:00
Andrea Canciani 92e24b9516 Expose the features computed from LLVM in `cfg!`
Instead of relying on the features explicitly passed through the
command line, compute them from the LLVM `TargetMachine`.
2016-04-09 00:41:23 +02:00
Jose Narvaez 4e64645228 Rustfmting librustc_driver. 2015-11-10 20:48:44 +00:00
Huon Wilson 4f4425840d Add some SIMD target_feature cfg's when appropriate.
NB. this may not be 100% perfect.
2015-08-17 14:41:37 -07:00