]> git.lizzy.rs Git - rust.git/commitdiff
Add AArch64 features
authorAmanieu d'Antras <amanieu@gmail.com>
Tue, 27 Feb 2018 02:05:58 +0000 (02:05 +0000)
committerAmanieu d'Antras <amanieu@gmail.com>
Wed, 28 Feb 2018 14:47:17 +0000 (14:47 +0000)
src/librustc_trans/attributes.rs
src/librustc_trans/llvm_util.rs

index 8309c91ab2573bcf4ee7f349cd9e7b45f79b3d05..57cd47063dcefbe7d8631db764fc4c84b5f3b7de 100644 (file)
@@ -212,7 +212,7 @@ fn from_target_feature(
         let value = value.as_str();
         for feature in value.split(',') {
             if whitelist.contains(feature) {
-                let llvm_feature = llvm_util::to_llvm_feature(feature);
+                let llvm_feature = llvm_util::to_llvm_feature(&tcx.sess, feature);
                 target_features.push(format!("+{}", llvm_feature));
                 continue
             }
index d80ef49d49ae788247ccf28a16bcd80bfb67569b..45445a48e233ed160b5ac6c743296d28e95b70ad 100644 (file)
@@ -81,7 +81,9 @@ unsafe fn configure_llvm(sess: &Session) {
 
 const ARM_WHITELIST: &'static [&'static str] = &["neon", "v7", "vfp2", "vfp3", "vfp4"];
 
-const AARCH64_WHITELIST: &'static [&'static str] = &["neon"];
+const AARCH64_WHITELIST: &'static [&'static str] = &["fp", "neon", "sve", "crc", "crypto",
+                                                     "ras", "lse", "rdm", "fp16", "rcpc",
+                                                     "dotprod", "v8.1a", "v8.2a", "v8.3a"];
 
 const X86_WHITELIST: &'static [&'static str] = &["aes", "avx", "avx2", "avx512bw",
                                                  "avx512cd", "avx512dq", "avx512er",
@@ -104,12 +106,18 @@ unsafe fn configure_llvm(sess: &Session) {
 
 const MIPS_WHITELIST: &'static [&'static str] = &["msa"];
 
-pub fn to_llvm_feature(s: &str) -> &str {
-    match s {
-        "pclmulqdq" => "pclmul",
-        "rdrand" => "rdrnd",
-        "bmi1" => "bmi",
-        s => s,
+pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
+    let arch = if sess.target.target.arch == "x86_64" {
+        "x86"
+    } else {
+        &*sess.target.target.arch
+    };
+    match (arch, s) {
+        ("x86", "pclmulqdq") => "pclmul",
+        ("x86", "rdrand") => "rdrnd",
+        ("x86", "bmi1") => "bmi",
+        ("aarch64", "fp16") => "fullfp16",
+        (_, s) => s,
     }
 }
 
@@ -118,7 +126,7 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
     target_feature_whitelist(sess)
         .iter()
         .filter(|feature| {
-            let llvm_feature = to_llvm_feature(feature);
+            let llvm_feature = to_llvm_feature(sess, feature);
             let cstr = CString::new(llvm_feature).unwrap();
             unsafe { llvm::LLVMRustHasFeature(target_machine, cstr.as_ptr()) }
         })