mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 00:26:57 +00:00
update detectAMDProcessor to detect znver4
This commit is contained in:
parent
78002dbe47
commit
3c21db6392
@ -58,7 +58,7 @@ pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, query: T
|
||||
detectIntelProcessor(&cpu, family, model, brand_id);
|
||||
},
|
||||
0x68747541 => {
|
||||
detectAMDProcessor(&cpu, family, model);
|
||||
if (detectAMDProcessor(cpu.features, family, model)) |m| cpu.model = m;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
@ -224,97 +224,43 @@ fn detectIntelProcessor(cpu: *Target.Cpu, family: u32, model: u32, brand_id: u32
|
||||
}
|
||||
}
|
||||
|
||||
fn detectAMDProcessor(cpu: *Target.Cpu, family: u32, model: u32) void {
|
||||
// AMD's cpuid information is less than optimal for determining a CPU model.
|
||||
// This is very unscientific, and not necessarily correct.
|
||||
switch (family) {
|
||||
4 => {
|
||||
cpu.model = &Target.x86.cpu.i486;
|
||||
return;
|
||||
fn detectAMDProcessor(features: Target.Cpu.Feature.Set, family: u32, model: u32) ?*const Target.Cpu.Model {
|
||||
return switch (family) {
|
||||
4 => &Target.x86.cpu.i486,
|
||||
5 => switch (model) {
|
||||
6, 7 => &Target.x86.cpu.k6,
|
||||
8 => &Target.x86.cpu.k6_2,
|
||||
9, 13 => &Target.x86.cpu.k6_3,
|
||||
10 => &Target.x86.cpu.geode,
|
||||
else => &Target.x86.cpu.pentium,
|
||||
},
|
||||
5 => {
|
||||
cpu.model = &Target.x86.cpu.pentium;
|
||||
switch (model) {
|
||||
6, 7 => {
|
||||
cpu.model = &Target.x86.cpu.k6;
|
||||
return;
|
||||
},
|
||||
8 => {
|
||||
cpu.model = &Target.x86.cpu.k6_2;
|
||||
return;
|
||||
},
|
||||
9, 13 => {
|
||||
cpu.model = &Target.x86.cpu.k6_3;
|
||||
return;
|
||||
},
|
||||
10 => {
|
||||
cpu.model = &Target.x86.cpu.geode;
|
||||
return;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
return;
|
||||
6 => if (Target.x86.featureSetHas(features, .sse))
|
||||
&Target.x86.cpu.athlon_xp
|
||||
else
|
||||
&Target.x86.cpu.athlon,
|
||||
15 => if (Target.x86.featureSetHas(features, .sse3))
|
||||
&Target.x86.cpu.k8_sse3
|
||||
else
|
||||
&Target.x86.cpu.k8,
|
||||
16 => &Target.x86.cpu.amdfam10,
|
||||
20 => &Target.x86.cpu.btver1,
|
||||
21 => switch (model) {
|
||||
0x60...0x7f => &Target.x86.cpu.bdver4,
|
||||
0x30...0x3f => &Target.x86.cpu.bdver3,
|
||||
0x02, 0x10...0x1f => &Target.x86.cpu.bdver2,
|
||||
else => &Target.x86.cpu.bdver1,
|
||||
},
|
||||
6 => {
|
||||
if (Target.x86.featureSetHas(cpu.features, .sse)) {
|
||||
cpu.model = &Target.x86.cpu.athlon_xp;
|
||||
return;
|
||||
}
|
||||
cpu.model = &Target.x86.cpu.athlon;
|
||||
return;
|
||||
22 => &Target.x86.cpu.btver2,
|
||||
23 => switch (model) {
|
||||
0x30...0x3f, 0x71 => &Target.x86.cpu.znver2,
|
||||
else => &Target.x86.cpu.znver1,
|
||||
},
|
||||
15 => {
|
||||
if (Target.x86.featureSetHas(cpu.features, .sse3)) {
|
||||
cpu.model = &Target.x86.cpu.k8_sse3;
|
||||
return;
|
||||
}
|
||||
cpu.model = &Target.x86.cpu.k8;
|
||||
return;
|
||||
25 => switch (model) {
|
||||
0x10...0x1f, 0x60...0x6f, 0x70...0x77, 0x78...0x7f, 0xa0...0xaf => &Target.x86.cpu.znver4,
|
||||
else => &Target.x86.cpu.znver3,
|
||||
},
|
||||
16 => {
|
||||
cpu.model = &Target.x86.cpu.amdfam10;
|
||||
return;
|
||||
},
|
||||
20 => {
|
||||
cpu.model = &Target.x86.cpu.btver1;
|
||||
return;
|
||||
},
|
||||
21 => {
|
||||
cpu.model = &Target.x86.cpu.bdver1;
|
||||
if (model >= 0x60 and model <= 0x7f) {
|
||||
cpu.model = &Target.x86.cpu.bdver4;
|
||||
return;
|
||||
}
|
||||
if (model >= 0x30 and model <= 0x3f) {
|
||||
cpu.model = &Target.x86.cpu.bdver3;
|
||||
return;
|
||||
}
|
||||
if ((model >= 0x10 and model <= 0x1f) or model == 0x02) {
|
||||
cpu.model = &Target.x86.cpu.bdver2;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
},
|
||||
22 => {
|
||||
cpu.model = &Target.x86.cpu.btver2;
|
||||
return;
|
||||
},
|
||||
23 => {
|
||||
cpu.model = &Target.x86.cpu.znver1;
|
||||
if ((model >= 0x30 and model <= 0x3f) or model == 0x71) {
|
||||
cpu.model = &Target.x86.cpu.znver2;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
},
|
||||
25 => {
|
||||
cpu.model = &Target.x86.cpu.znver3;
|
||||
return;
|
||||
},
|
||||
else => {
|
||||
return;
|
||||
},
|
||||
}
|
||||
else => null,
|
||||
};
|
||||
}
|
||||
|
||||
fn detectNativeFeatures(cpu: *Target.Cpu, os_tag: Target.Os.Tag) void {
|
||||
|
Loading…
Reference in New Issue
Block a user