about summary refs log tree commit diff
path: root/compiler/rustc_target/src
diff options
context:
space:
mode:
authorCaleb Zulawski <caleb.zulawski@gmail.com>2024-07-26 00:05:20 -0400
committerCaleb Zulawski <caleb.zulawski@gmail.com>2024-08-07 00:41:48 -0400
commit74653b61a67ae7db9f77ea1e09e65e40686c9058 (patch)
treec589eeb5a45e37481ce4a98efd90b0b09654ebe3 /compiler/rustc_target/src
parent6696447f784a888446d13bb400a8d507a68331c9 (diff)
downloadrust-74653b61a67ae7db9f77ea1e09e65e40686c9058.tar.gz
rust-74653b61a67ae7db9f77ea1e09e65e40686c9058.zip
Add implied target features to target_feature attribute
Diffstat (limited to 'compiler/rustc_target/src')
-rw-r--r--compiler/rustc_target/src/target_features.rs58
1 files changed, 52 insertions, 6 deletions
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index 4e2617c4679..5b79495831a 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -339,8 +339,6 @@ const WASM_ALLOWED_FEATURES: &[(&str, Stability)] = &[
     // tidy-alphabetical-end
 ];
 
-const WASM_IMPLICIT_FEATURES: &[(&str, &str)] = &[("relaxed-simd", "simd128")];
-
 const BPF_ALLOWED_FEATURES: &[(&str, Stability)] = &[("alu32", Unstable(sym::bpf_target_feature))];
 
 const CSKY_ALLOWED_FEATURES: &[(&str, Stability)] = &[
@@ -411,6 +409,54 @@ const IBMZ_ALLOWED_FEATURES: &[(&str, Stability)] = &[
     // tidy-alphabetical-end
 ];
 
+const X86_IMPLIED_FEATURES: &[(&str, &[&str])] = &[
+    // tidy-alphabetical-start
+    ("aes", &["sse2"]),
+    ("avx", &["sse4.2"]),
+    ("avx2", &["avx"]),
+    ("f16c", &["avx"]),
+    ("fma", &["avx"]),
+    ("pclmulqdq", &["sse2"]),
+    ("sha", &["sse2"]),
+    ("sse2", &["sse"]),
+    ("sse3", &["sse2"]),
+    ("sse4.1", &["ssse3"]),
+    ("sse4.2", &["sse4.1"]),
+    ("ssse3", &["sse3"]),
+    // tidy-alphabetical-end
+];
+
+const AARCH64_IMPLIED_FEATURES: &[(&str, &[&str])] = &[
+    // tidy-alphabetical-start
+    ("aes", &["neon"]),
+    ("f32mm", &["sve"]),
+    ("f64mm", &["sve"]),
+    ("fcma", &["neon"]),
+    ("fhm", &["fp16"]),
+    ("fp16", &["neon"]),
+    ("jsconv", &["neon"]),
+    ("rcpc2", &["rcpc"]),
+    ("sha2", &["neon"]),
+    ("sha3", &["sha2"]),
+    ("sm4", &["neon"]),
+    ("sve", &["fp16"]),
+    ("sve2", &["sve"]),
+    ("sve2-aes", &["sve2", "aes"]),
+    ("sve2-bitperm", &["sve2"]),
+    ("sve2-sha3", &["sve2", "sha3"]),
+    ("sve2-sm4", &["sve2", "sm4"]),
+    // tidy-alphabetical-end
+];
+
+const RISCV_IMPLIED_FEATURES: &[(&str, &[&str])] = &[
+    // tidy-alphabetical-start
+    ("zb", &["zba", "zbc", "zbs"]),
+    ("zk", &["zkn", "zkr", "zks", "zkt", "zbkb", "zbkc", "zkbx"]),
+    ("zkn", &["zknd", "zkne", "zknh", "zbkb", "zbkc", "zkbx"]),
+    ("zks", &["zksed", "zksh", "zbkb", "zbkc", "zkbx"]),
+    // tidy-alphabetical-end
+];
+
 /// When rustdoc is running, provide a list of all known features so that all their respective
 /// primitives may be documented.
 ///
@@ -458,11 +504,11 @@ impl super::spec::Target {
         }
     }
 
-    /// Returns a list of target features. Each items first target feature
-    /// implicitly enables the second one.
-    pub fn implicit_target_features(&self) -> &'static [(&'static str, &'static str)] {
+    pub fn implied_target_features(&self) -> &'static [(&'static str, &'static [&'static str])] {
         match &*self.arch {
-            "wasm32" | "wasm64" => WASM_IMPLICIT_FEATURES,
+            "aarch4" => AARCH64_IMPLIED_FEATURES,
+            "riscv32" | "riscv64" => RISCV_IMPLIED_FEATURES,
+            "x86" | "x86_64" => X86_IMPLIED_FEATURES,
             _ => &[],
         }
     }