Skip to content

Commit d3522d4

Browse files
committed
rustc_codegen_llvm: Merge match clauses
This commit merges multiple match clauses with the same LLVM version constraint and the same architecture for simplicity.
1 parent ef00680 commit d3522d4

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
244244
("aarch64", "paca") => Some(LLVMFeature::new("pauth")),
245245
("aarch64", "pacg") => Some(LLVMFeature::new("pauth")),
246246
// Before LLVM 20 those two features were packaged together as b16b16
247-
("aarch64", "sve-b16b16") if get_version().0 < 20 => Some(LLVMFeature::new("b16b16")),
248-
("aarch64", "sme-b16b16") if get_version().0 < 20 => Some(LLVMFeature::new("b16b16")),
247+
("aarch64", "sve-b16b16" | "sme-b16b16") if get_version().0 < 20 => {
248+
Some(LLVMFeature::new("b16b16"))
249+
}
249250
("aarch64", "flagm2") => Some(LLVMFeature::new("altnzcv")),
250251
// Rust ties fp and neon together.
251252
("aarch64", "neon") => Some(LLVMFeature::with_dependencies(
@@ -260,14 +261,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
260261
("aarch64", "fpmr") => None, // only existed in 18
261262
("arm", "fp16") => Some(LLVMFeature::new("fullfp16")),
262263
// NVPTX targets added in LLVM 20
263-
("nvptx64", "sm_100") if get_version().0 < 20 => None,
264-
("nvptx64", "sm_100a") if get_version().0 < 20 => None,
265-
("nvptx64", "sm_101") if get_version().0 < 20 => None,
266-
("nvptx64", "sm_101a") if get_version().0 < 20 => None,
267-
("nvptx64", "sm_120") if get_version().0 < 20 => None,
268-
("nvptx64", "sm_120a") if get_version().0 < 20 => None,
269-
("nvptx64", "ptx86") if get_version().0 < 20 => None,
270-
("nvptx64", "ptx87") if get_version().0 < 20 => None,
264+
(
265+
"nvptx64",
266+
"sm_100" | "sm_100a" | "sm_101" | "sm_101a" | "sm_120" | "sm_120a" | "ptx86" | "ptx87",
267+
) if get_version().0 < 20 => None,
271268
// Filter out features that are not supported by the current LLVM version
272269
("loongarch64", "div32" | "lam-bh" | "lamcas" | "ld-seq-sa" | "scq")
273270
if get_version().0 < 20 =>
@@ -301,12 +298,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
301298
("sparc", "v8plus") if get_version().0 == 19 => Some(LLVMFeature::new("v9")),
302299
("powerpc", "power8-crypto") => Some(LLVMFeature::new("crypto")),
303300
// These new `amx` variants and `movrs` were introduced in LLVM20
304-
("x86", "amx-avx512" | "amx-fp8" | "amx-movrs" | "amx-tf32" | "amx-transpose")
305-
if get_version().0 < 20 =>
306-
{
307-
None
308-
}
309-
("x86", "movrs") if get_version().0 < 20 => None,
301+
(
302+
"x86",
303+
"amx-avx512" | "amx-fp8" | "amx-movrs" | "amx-tf32" | "amx-transpose" | "movrs",
304+
) if get_version().0 < 20 => None,
310305
("x86", "avx10.1") => Some(LLVMFeature::new("avx10.1-512")),
311306
("x86", "avx10.2") => (get_version().0 >= 20).then(|| LLVMFeature::new("avx10.2-512")),
312307
("x86", "apxf") => Some(LLVMFeature::with_dependencies(

0 commit comments

Comments
 (0)