Skip to content

Commit 6361abc

Browse files
committed
rustc_codegen_llvm: Simplify arch conversion
This commit simplifies construction of `arch` from `sess.target.arch`. It also preserves a reference to `sess.target.arch` as `raw_arch` to make this function future proof.
1 parent a454fcc commit 6361abc

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,13 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
217217
/// Rust can also be build with an external precompiled version of LLVM which might lead to failures
218218
/// if the oldest tested / supported LLVM version doesn't yet support the relevant intrinsics.
219219
pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFeature<'a>> {
220-
let arch = if sess.target.arch == "x86_64" {
221-
"x86"
222-
} else if sess.target.arch == "arm64ec" {
223-
"aarch64"
224-
} else if sess.target.arch == "sparc64" {
225-
"sparc"
226-
} else if sess.target.arch == "powerpc64" {
227-
"powerpc"
228-
} else {
229-
&*sess.target.arch
220+
let raw_arch = &*sess.target.arch;
221+
let arch = match raw_arch {
222+
"x86_64" => "x86",
223+
"arm64ec" => "aarch64",
224+
"sparc64" => "sparc",
225+
"powerpc64" => "powerpc",
226+
_ => raw_arch,
230227
};
231228
match (arch, s) {
232229
("x86", "sse4.2") => Some(LLVMFeature::with_dependencies(

0 commit comments

Comments
 (0)