arch: x86_64: Collapse nested if into match arm guards

Do the necessary replacements to satisfy clippy::collapsible_match.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-05 23:12:18 +01:00
committed by Rob Bradford
parent b7b38df99c
commit ff39c35ac2

View File

@@ -643,15 +643,13 @@ pub fn generate_common_cpuid(
for entry in cpuid.as_mut_slice().iter_mut() {
match entry.function {
// Clear AMX related bits if the AMX feature is not enabled
0x7 => {
if !config.amx {
if entry.index == 0 {
entry.edx &= !((1 << AMX_BF16) | (1 << AMX_TILE) | (1 << AMX_INT8));
}
if entry.index == 1 {
entry.eax &= !(1 << AMX_FP16);
entry.edx &= !(1 << AMX_COMPLEX);
}
0x7 if !config.amx => {
if entry.index == 0 {
entry.edx &= !((1 << AMX_BF16) | (1 << AMX_TILE) | (1 << AMX_INT8));
}
if entry.index == 1 {
entry.eax &= !(1 << AMX_FP16);
entry.edx &= !(1 << AMX_COMPLEX);
}
}
0xd =>
@@ -673,55 +671,53 @@ pub fn generate_common_cpuid(
}
}
}
0x1d => {
// Tile Information (purely AMX related).
if !config.amx {
entry.eax = 0;
entry.ebx = 0;
entry.ecx = 0;
entry.edx = 0;
}
// Tile Information (purely AMX related).
0x1d if !config.amx => {
entry.eax = 0;
entry.ebx = 0;
entry.ecx = 0;
entry.edx = 0;
}
0x1e => {
// TMUL information (purely AMX related)
if !config.amx {
entry.eax = 0;
entry.ebx = 0;
entry.ecx = 0;
entry.edx = 0;
}
// TMUL information (purely AMX related)
0x1e if !config.amx => {
entry.eax = 0;
entry.ebx = 0;
entry.ecx = 0;
entry.edx = 0;
}
// Copy host L1 cache details if not populated by KVM
0x8000_0005 => {
if entry.eax == 0 && entry.ebx == 0 && entry.ecx == 0 && entry.edx == 0 {
#[allow(unused_unsafe)]
0x8000_0005
if entry.eax == 0
&& entry.ebx == 0
&& entry.ecx == 0
&& entry.edx == 0
// SAFETY: cpuid called with valid leaves
if unsafe { std::arch::x86_64::__cpuid(0x8000_0000).eax } >= 0x8000_0005 {
// SAFETY: cpuid called with valid leaves
let leaf = unsafe { std::arch::x86_64::__cpuid(0x8000_0005) };
entry.eax = leaf.eax;
entry.ebx = leaf.ebx;
entry.ecx = leaf.ecx;
entry.edx = leaf.edx;
}
}
&& unsafe { std::arch::x86_64::__cpuid(0x8000_0000).eax } >= 0x8000_0005 =>
{
// SAFETY: cpuid called with valid leaves
let leaf = unsafe { std::arch::x86_64::__cpuid(0x8000_0005) };
entry.eax = leaf.eax;
entry.ebx = leaf.ebx;
entry.ecx = leaf.ecx;
entry.edx = leaf.edx;
}
// Copy host L2 cache details if not populated by KVM
0x8000_0006 => {
if entry.eax == 0 && entry.ebx == 0 && entry.ecx == 0 && entry.edx == 0 {
#[allow(unused_unsafe)]
0x8000_0006
if entry.eax == 0
&& entry.ebx == 0
&& entry.ecx == 0
&& entry.edx == 0
// SAFETY: cpuid called with valid leaves
if unsafe { std::arch::x86_64::__cpuid(0x8000_0000).eax } >= 0x8000_0006 {
#[allow(unused_unsafe)]
// SAFETY: cpuid called with valid leaves
let leaf = unsafe { std::arch::x86_64::__cpuid(0x8000_0006) };
entry.eax = leaf.eax;
entry.ebx = leaf.ebx;
entry.ecx = leaf.ecx;
entry.edx = leaf.edx;
}
}
&& unsafe { std::arch::x86_64::__cpuid(0x8000_0000).eax } >= 0x8000_0006 =>
{
#[allow(unused_unsafe)]
// SAFETY: cpuid called with valid leaves
let leaf = unsafe { std::arch::x86_64::__cpuid(0x8000_0006) };
entry.eax = leaf.eax;
entry.ebx = leaf.ebx;
entry.ecx = leaf.ecx;
entry.edx = leaf.edx;
}
// Set CPU physical bits
0x8000_0008 => {