rustc_codegen_llvm: Reorder conversion cases

For maintainability, this commit reorders target feature conversion
cases by the architecture.
This commit is contained in:
Tsukasa OI
2025-09-17 12:35:21 +00:00
parent d9f67cbb8b
commit a1a3cd0438

View File

@@ -227,15 +227,6 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
};
let (major, _, _) = get_version();
match (arch, s) {
("x86", "sse4.2") => Some(LLVMFeature::with_dependencies(
"sse4.2",
smallvec![TargetFeatureFoldStrength::EnableOnly("crc32")],
)),
("x86", "pclmulqdq") => Some(LLVMFeature::new("pclmul")),
("x86", "rdrand") => Some(LLVMFeature::new("rdrnd")),
("x86", "bmi1") => Some(LLVMFeature::new("bmi")),
("x86", "cmpxchg16b") => Some(LLVMFeature::new("cx16")),
("x86", "lahfsahf") => Some(LLVMFeature::new("sahf")),
("aarch64", "rcpc2") => Some(LLVMFeature::new("rcpc-immo")),
("aarch64", "dpb") => Some(LLVMFeature::new("ccpp")),
("aarch64", "dpb2") => Some(LLVMFeature::new("ccdp")),
@@ -259,13 +250,22 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
("arm", "fp16") => Some(LLVMFeature::new("fullfp16")),
// Filter out features that are not supported by the current LLVM version
("loongarch32" | "loongarch64", "32s") if major < 21 => None,
("powerpc", "power8-crypto") => Some(LLVMFeature::new("crypto")),
("sparc", "leoncasa") => Some(LLVMFeature::new("hasleoncasa")),
("x86", "sse4.2") => Some(LLVMFeature::with_dependencies(
"sse4.2",
smallvec![TargetFeatureFoldStrength::EnableOnly("crc32")],
)),
("x86", "pclmulqdq") => Some(LLVMFeature::new("pclmul")),
("x86", "rdrand") => Some(LLVMFeature::new("rdrnd")),
("x86", "bmi1") => Some(LLVMFeature::new("bmi")),
("x86", "cmpxchg16b") => Some(LLVMFeature::new("cx16")),
("x86", "lahfsahf") => Some(LLVMFeature::new("sahf")),
// Enable the evex512 target feature if an avx512 target feature is enabled.
("x86", s) if s.starts_with("avx512") => Some(LLVMFeature::with_dependencies(
s,
smallvec![TargetFeatureFoldStrength::EnableOnly("evex512")],
)),
("sparc", "leoncasa") => Some(LLVMFeature::new("hasleoncasa")),
("powerpc", "power8-crypto") => Some(LLVMFeature::new("crypto")),
("x86", "avx10.1") => Some(LLVMFeature::new("avx10.1-512")),
("x86", "avx10.2") => Some(LLVMFeature::new("avx10.2-512")),
("x86", "apxf") => Some(LLVMFeature::with_dependencies(