Skip to content

Commit b728626

Browse files
Rollup merge of rust-lang#155235 - folkertdev:fma4-target-feature, r=sayantn
add the `fma4` x86 target feature tracking issue: rust-lang#155233 Implications are based on LLVM https://github.com/llvm/llvm-project/blob/df6c82053c5e1f9814d130d423f34871bc6423c5/llvm/lib/Target/X86/X86.td#L201-L206 This feature adds a slightly better instruction encoding for fma. We might want to expose the intrinsics in `stdarch` with that target feature, but just adding the target feature in user code should already take advantage of this improved encoding. This target feature is used in `libm`. r? sayantn
2 parents 5da0b6c + c766242 commit b728626

7 files changed

Lines changed: 28 additions & 4 deletions

File tree

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ declare_features! (
512512
(incomplete, field_projections, "CURRENT_RUSTC_VERSION", Some(145383)),
513513
/// Allows marking trait functions as `final` to prevent overriding impls
514514
(unstable, final_associated_functions, "1.95.0", Some(131179)),
515+
/// fma4 target feature on x86.
516+
(unstable, fma4_target_feature, "CURRENT_RUSTC_VERSION", Some(155233)),
515517
/// Controlling the behavior of fmt::Debug
516518
(unstable, fmt_debug, "1.82.0", Some(129709)),
517519
/// Allows using `#[align(...)]` on function items

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ symbols! {
952952
floorf32,
953953
floorf64,
954954
floorf128,
955+
fma4_target_feature,
955956
fmaf16,
956957
fmaf32,
957958
fmaf64,

compiler/rustc_target/src/target_features.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
422422
("ermsb", Unstable(sym::ermsb_target_feature), &[]),
423423
("f16c", Stable, &["avx"]),
424424
("fma", Stable, &["avx"]),
425+
("fma4", Unstable(sym::fma4_target_feature), &["avx", "sse4a"]),
425426
("fxsr", Stable, &[]),
426427
("gfni", Stable, &["sse2"]),
427428
("kl", Stable, &["sse2"]),
@@ -467,7 +468,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
467468
("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
468469
("widekl", Stable, &["kl"]),
469470
("x87", Unstable(sym::x87_target_feature), &[]),
470-
("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]),
471+
("xop", Unstable(sym::xop_target_feature), &["fma4", "avx", "sse4a"]),
471472
("xsave", Stable, &[]),
472473
("xsavec", Stable, &["xsave"]),
473474
("xsaveopt", Stable, &["xsave"]),

tests/ui/check-cfg/target_feature.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
111111
`float7e60`
112112
`floate1`
113113
`fma`
114+
`fma4`
114115
`fp-armv8`
115116
`fp16`
116117
`fp64`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ only-x86_64
2+
#[target_feature(enable = "fma4")]
3+
//~^ ERROR: currently unstable
4+
unsafe fn foo() {}
5+
6+
fn main() {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0658]: the target feature `fma4` is currently unstable
2+
--> $DIR/feature-gate-fma4_target_feature.rs:2:18
3+
|
4+
LL | #[target_feature(enable = "fma4")]
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #155233 <https://github.com/rust-lang/rust/issues/155233> for more information
8+
= help: add `#![feature(fma4_target_feature)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0658`.

tests/ui/target-feature/invalid-attribute.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ error: the feature named `foo` is not valid for this target
161161
LL | #[target_feature(enable = "foo")]
162162
| ^^^^^^^^^^^^^^ `foo` is not valid for this target
163163
|
164-
= help: valid names are: `fma`, `xop`, `adx`, `aes`, and `avx` and 74 more
164+
= help: valid names are: `fma`, `xop`, `adx`, `aes`, and `avx` and 75 more
165165

166166
error[E0046]: not all trait items implemented, missing: `foo`
167167
--> $DIR/invalid-attribute.rs:81:1
@@ -213,15 +213,15 @@ error: the feature named `sse5` is not valid for this target
213213
LL | #[target_feature(enable = "sse5")]
214214
| ^^^^^^^^^^^^^^^ `sse5` is not valid for this target
215215
|
216-
= help: valid names are: `sse`, `sse2`, `sse3`, `sse4a`, and `ssse3` and 74 more
216+
= help: valid names are: `sse`, `sse2`, `sse3`, `sse4a`, and `ssse3` and 75 more
217217

218218
error: the feature named `avx512` is not valid for this target
219219
--> $DIR/invalid-attribute.rs:127:18
220220
|
221221
LL | #[target_feature(enable = "avx512")]
222222
| ^^^^^^^^^^^^^^^^^ `avx512` is not valid for this target
223223
|
224-
= help: valid names are: `avx512f`, `avx2`, `avx512bw`, `avx512cd`, and `avx512dq` and 74 more
224+
= help: valid names are: `avx512f`, `avx2`, `avx512bw`, `avx512cd`, and `avx512dq` and 75 more
225225

226226
error: aborting due to 26 previous errors
227227

0 commit comments

Comments
 (0)