Skip to content

Commit 2b3c815

Browse files
kennytmManishearth
authored andcommitted
Rollup merge of #48570 - Amanieu:aarch64_features, r=alexcrichton
Add AArch64 features to whitelist
2 parents a080d7b + f756ad3 commit 2b3c815

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/librustc_trans/attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn from_target_feature(
212212
let value = value.as_str();
213213
for feature in value.split(',') {
214214
if whitelist.contains(feature) {
215-
let llvm_feature = llvm_util::to_llvm_feature(feature);
215+
let llvm_feature = llvm_util::to_llvm_feature(&tcx.sess, feature);
216216
target_features.push(format!("+{}", llvm_feature));
217217
continue
218218
}

src/librustc_trans/llvm_util.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ unsafe fn configure_llvm(sess: &Session) {
8181

8282
const ARM_WHITELIST: &'static [&'static str] = &["neon", "v7", "vfp2", "vfp3", "vfp4"];
8383

84-
const AARCH64_WHITELIST: &'static [&'static str] = &["neon", "v7"];
84+
const AARCH64_WHITELIST: &'static [&'static str] = &["fp", "neon", "sve", "crc", "crypto",
85+
"ras", "lse", "rdm", "fp16", "rcpc",
86+
"dotprod", "v8.1a", "v8.2a", "v8.3a"];
8587

8688
const X86_WHITELIST: &'static [&'static str] = &["aes", "avx", "avx2", "avx512bw",
8789
"avx512cd", "avx512dq", "avx512er",
@@ -104,12 +106,18 @@ const POWERPC_WHITELIST: &'static [&'static str] = &["altivec",
104106

105107
const MIPS_WHITELIST: &'static [&'static str] = &["msa"];
106108

107-
pub fn to_llvm_feature(s: &str) -> &str {
108-
match s {
109-
"pclmulqdq" => "pclmul",
110-
"rdrand" => "rdrnd",
111-
"bmi1" => "bmi",
112-
s => s,
109+
pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
110+
let arch = if sess.target.target.arch == "x86_64" {
111+
"x86"
112+
} else {
113+
&*sess.target.target.arch
114+
};
115+
match (arch, s) {
116+
("x86", "pclmulqdq") => "pclmul",
117+
("x86", "rdrand") => "rdrnd",
118+
("x86", "bmi1") => "bmi",
119+
("aarch64", "fp16") => "fullfp16",
120+
(_, s) => s,
113121
}
114122
}
115123

@@ -118,7 +126,7 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
118126
target_feature_whitelist(sess)
119127
.iter()
120128
.filter(|feature| {
121-
let llvm_feature = to_llvm_feature(feature);
129+
let llvm_feature = to_llvm_feature(sess, feature);
122130
let cstr = CString::new(llvm_feature).unwrap();
123131
unsafe { llvm::LLVMRustHasFeature(target_machine, cstr.as_ptr()) }
124132
})

0 commit comments

Comments
 (0)