about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-01 21:37:18 +0800
committerManish Goregaokar <manishsmail@gmail.com>2018-03-01 09:29:43 -0800
commit2b3c815ddfefcabd3231ea3bb82443853f2e2254 (patch)
treea5062c1142448b959ae760a081ba0bc27a16eee4
parenta080d7b2b2829257fe09ea5fe2193423740db432 (diff)
parentf756ad3d9478a5b82b0dfb304bf31b46a031ed08 (diff)
downloadrust-2b3c815ddfefcabd3231ea3bb82443853f2e2254.tar.gz
rust-2b3c815ddfefcabd3231ea3bb82443853f2e2254.zip
Rollup merge of #48570 - Amanieu:aarch64_features, r=alexcrichton
Add AArch64 features to whitelist
-rw-r--r--src/librustc_trans/attributes.rs2
-rw-r--r--src/librustc_trans/llvm_util.rs24
2 files changed, 17 insertions, 9 deletions
diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs
index 8309c91ab25..57cd47063dc 100644
--- a/src/librustc_trans/attributes.rs
+++ b/src/librustc_trans/attributes.rs
@@ -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
             }
diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs
index 00ac9d80245..45445a48e23 100644
--- a/src/librustc_trans/llvm_util.rs
+++ b/src/librustc_trans/llvm_util.rs
@@ -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", "v7"];
+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 @@ const POWERPC_WHITELIST: &'static [&'static str] = &["altivec",
 
 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()) }
         })